Skip to content
This repository has been archived by the owner on May 21, 2022. It is now read-only.

Header non-string values #46

Closed
egze opened this issue Dec 13, 2019 · 5 comments
Closed

Header non-string values #46

egze opened this issue Dec 13, 2019 · 5 comments

Comments

@egze
Copy link
Contributor

egze commented Dec 13, 2019

I'm using mojito as a Http client for ExAws.

defmodule MyApp.S3.HttpClient do
  @behaviour ExAws.Request.HttpClient
  def request(method, url, body, headers, http_opts \\ []) do
    Mojito.request(method, url, headers, body, http_opts)
  end
end

When trying to download a file, I'm getting:

error] GenServer #PID<0.637.0> terminating
** (FunctionClauseError) no function clause matching in Mint.HTTP1.Request."-validate_header_value!/2-lc$^0/1-0-"/1

Last message (from #PID<0.478.0>): {:request, %Mojito.Request{body: "", headers: [{"x-amz-date", "20191213T171338Z"}, {"content-length", 0}], method: :head, opts: [], url: "https://s3.eu-central-1.amazonaws.com/bucket/file"}, #PID<0.478.0>, #Reference<0.938540534.2258632705.207122>}
State: %{conn: nil, hostname: nil, port: nil, protocol: nil, reply_tos: %{}, response_refs: %{}, responses: %{}}
Client #PID<0.478.0> is alive

This is happening because of this part {"content-length", 0}, if I preprocess the headers and convert the values to strings, then it works.

Should mojito be more permissive, and auto-convert the values? Will gladly do a PR.

@gamache
Copy link
Contributor

gamache commented Jan 21, 2020

Hi there! Sorry for the delayed reply. Your idea is a good one and I would happily accept a PR.

@egze
Copy link
Contributor Author

egze commented Jan 22, 2020

@gamache Now that I think about it, maybe it's better to fix it in Mint? Somewhere here: https://github.com/elixir-mint/mint/blob/master/lib/mint/http1.ex#L237

What do you think?

@egze
Copy link
Contributor Author

egze commented Jan 24, 2020

Let's see what Mint folks say.
elixir-mint/mint#235

@egze
Copy link
Contributor Author

egze commented Jan 24, 2020

Ok, let's fix it in Mojito :)

@gamache
Copy link
Contributor

gamache commented Mar 11, 2020

Fixed in 0.6.2.

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

No branches or pull requests

2 participants