AFNetworking Enable GZIP

为君一笑 提交于 2019-12-04 16:51:14

问题


I am looking on the AFNetworking site that GZIP compression is supported " Gzip decompression from server responses is already built into AFNetworking, as NSURLConnection will automatically decompress responses with the Content-Encoding: gzip HTTP header. " - AFNetworking FAQ

How do I enable GZIP compression so I can pull data from the server compressed or is it already defaulting to this?

Thanks!


回答1:


AFAIK NSURLConnection uses gzip decompresson by default and AFNetworking builds on the top of NSURLConnection. So, you shouldn't have to enable it.




回答2:


It seems you need to add a HTTP header :

[self setDefaultHeader:@"Accept-Encoding" value:@"gzip"]

To the AfNetworking HTTP client.



来源:https://stackoverflow.com/questions/16423166/afnetworking-enable-gzip

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!