Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ipv6 localhost address is passed to hackney without square brackets #475

Open
philippseith opened this issue Apr 8, 2023 · 1 comment
Open

Comments

@philippseith
Copy link

philippseith commented Apr 8, 2023

I am trying to build a simple reverse proxy with https://hexdocs.pm/reverse_proxy_plug and its httpoison plugin. I am trying to forward requests to a (angular dev-). server, listening on localhost:4200.
As localhost is ipv6 on macOS and hackney does not seem to resolve this correctly (see benoitc/hackney#718), I set the upstream to "http://[::1]:4200/" which reaches :hackney.request/5 as "http://::1:4200" and causes

 1st argument: not a textual representation of an integer

        :erlang.list_to_integer(':1:4200')
        (hackney 1.18.1) /Users/philipp/wspc/elixir/rest_api/deps/hackney/src/hackney_url.erl:260: :hackney_url.parse_netloc/2
        (hackney 1.18.1) /Users/philipp/wspc/elixir/rest_api/deps/hackney/src/hackney.erl:351: :hackney.request/5

IMHO the square brackets must not be removed from the url.

used versions:
OTP 25
Elixir 1.14.1
Httpoison 2.1.0
hackney 1.18.1

@Chlorophytus
Copy link

I got Elixir 1.14.5 set up with lighttpd hosting a single file bound on that [::1] IP address. It's also using Erlang/OTP 25.3.2.6.

iex> HTTPoison.get!("[::1]:8080/index.txt")
%HTTPoison.Response{
  status_code: 200,
  body: "Hello, Elixir!\n",
  headers: [
    {"Content-Type", "text/plain;charset=utf-8"},
    {"ETag", "\"4116816263\""},
    {"Last-Modified", "Fri, 06 Oct 2023 20:43:35 GMT"},
    {"Content-Length", "15"},
    {"Accept-Ranges", "bytes"},
    {"Date", "Fri, 06 Oct 2023 20:55:21 GMT"},
    {"Server", "lighttpd/1.4.71"}
  ],
  request_url: "http://[::1]:8080/index.txt",
  request: %HTTPoison.Request{
    method: :get,
    url: "http://[::1]:8080/index.txt",
    headers: [],
    body: "",
    params: %{},
    options: []
  }
}

I'm not sure how to reproduce the bug, did it get fixed on your end?

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

No branches or pull requests

2 participants