NSURLConnection/NSURLRequest gzip support

mxg picture mxg · Apr 21, 2010 · Viewed 24.2k times · Source

Does anyone knows if NSURLConnection/NSURLRequest have support for gzip requests.

If does, can you provide more information?

Answer

ax. picture ax. · Apr 21, 2010

although it does not seem to be documented, there is evidence that NSURLConnection does have transparent gzip support. meaning that if the server supports gzip encoding, and your request has an Accept-Encoding header containing gzip*, the server will send a gzipped response, which NSURLConnection will automatically decode.

* NSURLRequest might add that header by default. if not, you have to add it manually like so:

 [urlReq setValue:@"gzip" forHTTPHeaderField:@"Accept-Encoding"]