NSURLConnection / NSURLRequest gzip支持 [英] NSURLConnection/NSURLRequest gzip support
问题描述
有人知道NSURLConnection / NSURLRequest是否支持gzip请求。
Does anyone knows if NSURLConnection/NSURLRequest have support for gzip requests.
如果可以,您能提供更多信息吗?
If does, can you provide more information?
提前感谢!
推荐答案
虽然它似乎没有记录,有证据表明 NSURLConnection
有透明的gzip支持。意味着如果服务器支持gzip编码,并且您的请求有包含 gzip
*的 Accept-Encoding
将发送一个gzip压缩的响应, NSURLConnection
将自动解码。
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
可能会添加该标题。
* NSURLRequest
might add that header by default. if not, you have to add it manually like so:
[urlReq setValue:@"gzip" forHTTPHeaderField:@"Accept-Encoding"]
这篇关于NSURLConnection / NSURLRequest gzip支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!