Get content length from gzipped NSURLResponse

时间:2016-04-04 16:51:52

标签: ios nsurlconnection nsurlsession

I'm using NSURLSession's dataTaskWithRequest to perform an HTTP GET with Accept-Encoding: gzip. NSURLSession will automatically un-gzip the gzipped stream. How can I get the original response's content length (i.e. the length before un-gzipping)? Note that:

  • NSURLResponse's expectedContentLength is the length after un-gzipping it.
  • NSURLSessionTask's countOfBytesReceived property is the same value as expectedContentLength
  • While the header Content-Length can be obtained from NSHTTPURLResponse, it's not available with HTTP 1.1's chunked transfer encoding.

0 个答案:

没有答案
相关问题