NSURLConnection/NSURLRequest gzip 支持 [英] NSURLConnection/NSURLRequest gzip support

查看:27
本文介绍了NSURLConnection/NSURLRequest gzip 支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆