Question

My iOS app is using ASIHTTPREQUEST to download files from a server. It works well, but uiprogressview doesn't.

So I use code to check the header information:

ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://www.ozis.com.au/nm.pdf"]];
[request startSynchronous];
NSLog(@"%@",[request responseHeaders]);

Then I find there is no content-length response. The result shows like below:

"Accept-Ranges" = bytes;
Connection = "Keep-Alive";
"Content-Encoding" = gzip;
"Content-Type" = "application/pdf";
Date = "Sat, 06 Oct 2012 13:47:15 GMT";
Etag = "\"2b5139-ddf639-4cafe418b6140\"";
"Keep-Alive" = "timeout=10, max=30";
"Last-Modified" = "Mon, 01 Oct 2012 12:07:57 GMT";
Server = Apache;
"Transfer-Encoding" = Identity;
Vary = "Accept-Encoding";

But sometimes, maybe 5% chance, I can get its length after a long long time waiting. This PDF file is 13 MB. Other files at same place can be get correct length.

What should I do?

Was it helpful?

Solution

Finally, I made it out. Because my server gzip-ed the PDF file automatically so I cannot get content-length as response.

To turn off gzip function just simply add

SetEnv no-gzip dont-vary

in .htaccess file. That's it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top