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

Does Mojito support a way to specify between HTTP/1 or HTTP/2? #41

Closed edisonywh closed 4 years ago

edisonywh commented 4 years ago

I am hitting a bug in my code that looks something like this:

{:error, %Mojito.Error{message: nil, reason: %Mint.HTTPError{module: Mint.HTTP2, reason: {:exceeds_window_size, :connection, 65535}}}}

Upon some inspection, it looks like it's a HTTP/2 specific thing, so I went digging to see if there's a way for me to specify to use HTTP/2 instead. I can't really find anything in the Mojito doc, but I managed to find out that Mint does support it over here, so just curious if Mojito can support that?

edisonywh commented 4 years ago

What do you know, I digged in a little bit more and found that Mojito just passes down the opts down, and it ultimately ends up untouched to Mint, so something like this works:

      Mojito.post(
        @endpoint,
        [{"content-type", "application/json"}],
        Jason.encode!(%{body: dirty}),
        timeout: 10_000,
        protocols: [:http1]
      )

Going to close this now, sorry!