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
Content-Length
can be obtained from NSHTTPURLResponse
, it's not available with HTTP 1.1's chunked transfer encoding.