Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AFNetworking Enable GZIP

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!

like image 671
Alan Avatar asked May 07 '13 15:05

Alan


2 Answers

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

like image 194
vbali Avatar answered Nov 01 '22 17:11

vbali


It seems you need to add a HTTP header :

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

To the AfNetworking HTTP client.

like image 7
Thomas Decaux Avatar answered Nov 01 '22 15:11

Thomas Decaux