lostisland / faraday_middleware

Various Faraday middlewares for Faraday-based API wrappers
MIT License
556 stars 205 forks source link

Fix support for empty bodies having Content-Encoding Gzip #192

Closed GibzonDev closed 5 years ago

GibzonDev commented 5 years ago

Sometimes empty bodies can be received together with a Content-Encoding of, for example, "gzip". I've come across this a few times working with external API:s which send a 304 (Do not modify), together with a empty body and Content-Encoding "Gzip".

With these changes, Faraday won't raise an unknown gzip format exception, but rather just not try to decompress the body.

Example of similar fix in okhttp: https://github.com/square/okhttp/issues/268