edgurgel / edgurgel/httpoison

ipv6 localhost address is passed to hackney without square brackets

Open
#475 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Elixir
Stars
2.3k
Forks
349
PR merge metrics
No merged PRs in 30d

Description

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 https://github.com/benoitc/hackney/issues/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

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the failure with the upstream URL "http://[::1]:4200/" and inspect the stack trace around hackney_url.erl:260 and hackney.erl:351. Trace how Httpoison passes the URL to hackney; done means the IPv6 address retains its square brackets and the request reaches the localhost server.

Written by the indexing model from the issue text.

Assessment

Tech stack
elixir
Domain
backend, networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.