Ios ASIHTTPREQUEST无内容长度响应(大PDF文件)

Ios ASIHTTPREQUEST无内容长度响应(大PDF文件),ios,xcode,asihttprequest,content-length,Ios,Xcode,Asihttprequest,Content Length,我的iOS应用程序正在使用ASIHTTPREQUEST从服务器下载文件。它工作得很好,但uiprogressview不行 因此,我使用代码检查标题信息: ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://www.ozis.com.au/nm.pdf"]]; [request startSynchronous]; NSLog(@"%@",[request responseHe

我的iOS应用程序正在使用ASIHTTPREQUEST从服务器下载文件。它工作得很好,但uiprogressview不行

因此,我使用代码检查标题信息:

ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://www.ozis.com.au/nm.pdf"]];
[request startSynchronous];
NSLog(@"%@",[request responseHeaders]);
然后我发现没有内容长度的响应。结果如下:

"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";
但有时,也许5%的机会,我可以得到它的长度后,等待了很长时间。这个PDF文件是13MB。同一位置的其他文件可以获得正确的长度


我该怎么办?

最后,我成功了。因为我的服务器gzip自动编辑了PDF文件,所以我无法获得内容长度作为响应

要关闭gzip函数,只需添加

SetEnv no-gzip dont-vary
.htaccess
文件中。就这样