That's just a question.
Does Alamofire work with gzip?
Thanks a lot.
What do you mean by "work with gzip"?
If you mean: "Does it handle gzipped responses", then yes. (I think this is handled further down at the cocoa layer?)
Those will be uncompressed for you.
Thanks, @tkrajacic. You are correct鈥攖he underlying Foundation URL Loading System handles this automatically.
For all the people coming here like me wondering how to GZIP the body of the request produced by Alamofire's ParameterEncoding I have made a little extension.
Provided you use: https://github.com/1024jp/NSData-GZIP
With this extension you can now gzip your request by calling .gzipped on the encoding.
Examples:
Alamofire.request(.POST, someURLString, parameters:["data":["verboseData":"veryVerbose"]], encoding:.JSON.gzipped)
@blender, I am struggling using your NSData extension. Just posted a question in your Issues on GitHub would be grateful for your assistance
@Hakkoos unfortunately I'm not the maintainer nor work on https://github.com/1024jp/NSData-GZIP. I'm afraid I can't help you there.
Thanks @blender
Hey all,
Just needed to zip the JSON body of an Alamofire Request and end up in this post, too bad it's not compatible with Alamofire right now.
But I've created a new ParameterEncoding class that uses Gzip compression for the JSON request and it works flawlessly.
Here it is.
You just use it this way:
Alamofire.request(url, method: method, parameters: parameters, encoding: GZIPEncoding(), headers: mHeaders).response...
Cheers!
Hello, I used your extension..but it still give me error like cannot decode raw data when I encode GZip data.
Most helpful comment
Hey all,
Just needed to zip the JSON body of an Alamofire Request and end up in this post, too bad it's not compatible with Alamofire right now.
But I've created a new ParameterEncoding class that uses Gzip compression for the JSON request and it works flawlessly.
Here it is.
You just use it this way:
Alamofire.request(url, method: method, parameters: parameters, encoding: GZIPEncoding(), headers: mHeaders).response...Cheers!