Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove Accept-Encoding from Alamofire

Tags:

alamofire

By default Alamofire is sending an Accept-Encoding header that includes gzip. How do I tell it to stop doing that? I do accept gzip, and I'm glad to have Alamofire parse it out for me, but when you send that header, ngix immediately removes the Content-Length header (ARGH!!!!) and that breaks things for me.

like image 929
Gargoyle Avatar asked Nov 10 '22 01:11

Gargoyle


1 Answers

I found that alamofire adds the following headers:

Accept-Language: en;q=1.0

Accept-Encoding: gzip;q=1.0, compress;q=0.5

the q= part was the problematic part and what caused my server to return an error.

To solve it i added my own Accept-Language and Accept-Encoding headers to override the default headers. mine were without the q= part.

    headers["Accept-Language"] = "en"
    headers["Accept-Encoding"] = "gzip"

That did the trick, hope it will be of help to someone.

like image 190
Boaz Saragossi Avatar answered Jan 04 '23 01:01

Boaz Saragossi