I have an NSURLConnection and in didReceiveResponse
I'm checking [response expectedContentLength]
and getting really large values like 18446744073709551615. There's no way this is correct. The download is about 3k bytes, and when I expect the same request in fiddler, I see a (correct) content length header in the response of about 3k bytes.
Asked
Active
Viewed 792 times
3

xdumaine
- 10,096
- 6
- 62
- 103
-
Are you using that `Accept-Encoding: gzip` in your request? Perhaps you can edit your question to share your code that is formulating the request (if you're doing anything with the request). And, if you're willing, the URL, too. – Rob Feb 08 '13 at 16:01
-
@Rob I'm not using accept-encoding: gzip in my request. In fact, I *tried* to set the accept-encoding header to an empty string, to prevent the server from using gzip, but it didn't have any effect. I can't share the URL, as it's a customer API, but it looks like their server always gzips the response, so what I'm trying to do won't work. – xdumaine Feb 08 '13 at 16:34
-
Understood. I (like you, I'm sure) dug around for work-arounds, but couldn't find any. Sorry. Good luck. – Rob Feb 08 '13 at 17:27
-
Can you share the HTTP response headers? If you have the DECODE option set in Fiddler's toolbar, does the problem go away? – EricLaw Feb 08 '13 at 20:11
2 Answers
3
To avoid this problem, set header field "Accept-Encoding" to @"gzip;q=0". that tells the server that you do not accept gzip, and will if possible send uncompressed.

Bjørn Ruthberg
- 336
- 1
- 15
-
See the comments on the question. I tried that, and this particular server doesn't accept it. – xdumaine Jul 03 '13 at 12:32
-
The above didn't work for me, though using a value of `identity` for `Accept-Encoding` did. – Rob May 23 '14 at 18:28
2
The answer, related to the comments, is that it's because the result is gzip encoded. Oddly, the value for the expectedContentLength
seems to be junk, and cannot be trusted. If the result is gzip encoded, then NSURLConnection
cannot properly determine the size of the unencoded result.

xdumaine
- 10,096
- 6
- 62
- 103