Why does my NSURLConnection report an incorrect expectedContentLength

前端 未结 2 1173
深忆病人
深忆病人 2020-12-11 22:56

I have an NSURLConnection and in didReceiveResponse I\'m checking [response expectedContentLength] and getting really large values like 18446744073

相关标签:
2条回答
  • 2020-12-11 23:25

    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.

    0 讨论(0)
  • 2020-12-11 23:25

    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.

    0 讨论(0)
提交回复
热议问题