Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does it work with gzip? #256

Closed
gabrielribeiro opened this issue Dec 13, 2014 · 8 comments
Closed

Does it work with gzip? #256

gabrielribeiro opened this issue Dec 13, 2014 · 8 comments

Comments

@gabrielribeiro
Copy link

That's just a question.
Does Alamofire work with gzip?
Thanks a lot.

@tkrajacic
Copy link

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.

@mattt
Copy link
Sponsor Contributor

mattt commented Dec 13, 2014

Thanks, @tkrajacic. You are correct—the underlying Foundation URL Loading System handles this automatically.

@mattt mattt closed this as completed Dec 13, 2014
@tmspzz
Copy link

tmspzz commented Oct 22, 2015

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)

@Hakkoos
Copy link

Hakkoos commented Sep 1, 2016

@blender, I am struggling using your NSData extension. Just posted a question in your Issues on GitHub would be grateful for your assistance

@tmspzz
Copy link

tmspzz commented Sep 1, 2016

@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.

@Hakkoos
Copy link

Hakkoos commented Sep 1, 2016

Thanks @blender

@kh4zad
Copy link

kh4zad commented Jan 31, 2018

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!

@axita27
Copy link

axita27 commented Jul 4, 2019

Hello, I used your extension..but it still give me error like cannot decode raw data when I encode GZip data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants