appcues / mojito

An easy-to-use Elixir HTTP client, built on the low-level Mint library.
https://hexdocs.pm/mojito/Mojito.html
MIT License
349 stars 34 forks source link

Disabling transfer-encoding: chunked #80

Closed avaitla closed 2 years ago

avaitla commented 3 years ago

Hello Team,

I've noticed an issue when using mojito to send post requests to a third party service: https://sheet.best/

When making a POST request with Mojito the service doesn't work, whereas the same post request sent from curl or httppoison does work (so it is not an issue with the third party service).

The reason the service doesn't work when requested with Mojito is due to Mojito forcing the transfer-encoding: chunked format on the request. I've written a quick gist comparing outputs between curl / httppoison / mojito: https://gist.github.com/avaitla/0d6fc2e1ee7a01325cda8e0e5dd28bae

Note that Mojito does NOT return the right results, since sheet.best cannot understand chunked transfer encoding.

Is there anyway that users of this library can disable this feature as not all external services (which we cannot control may not support this encoding).

Thank you,

esvinson commented 3 years ago

We're seeing something similar. This looks like it was a breaking change in 0.7.6. If I revert back to our previous version (0.7.3 ) our requests work just fine. If we switch to the latest version (0.7.7) we start getting 404 errors from the login.microsoftonline.com authentication URL we're hitting.

gamache commented 3 years ago

Hm, this would be a consequence of #68, which forces chunked behavior in HTTP/1 as a side effect of implementing it in HTTP/2. It's not necessary to implement it this way; if it's causing problems like this, we should restore the original behavior.

ihabunek commented 3 years ago

This issue also breaks fetching auth keys from Apple, as their server returns a 403 when transfer-encoding: chunked header is sent.

Mojito.get("https://appleid.apple.com/auth/keys")                        
ntenczar commented 2 years ago

Hi! This project is now deprecated:

We recommend that you use Finch which is also built on Mint. The creator of Finch has an excellent writeup here describing the problems with Mojito, and as a result we use Finch internally at Appcues now.