aboutsummaryrefslogtreecommitdiffstats
path: root/lib/inets
diff options
context:
space:
mode:
authorIngela Anderton Andin <[email protected]>2019-01-23 15:36:34 +0100
committerIngela Anderton Andin <[email protected]>2019-01-23 15:36:34 +0100
commitc0f1b4ebb0a532d90a1da18144dff7a645d83220 (patch)
tree38ff97196288cd7f9308c393e0252226b56373ab /lib/inets
parent1618464b1c399b7739529ae6ab182a0cdebcc84e (diff)
parentf6d76e0c76591721baab85d249685104daad94e5 (diff)
downloadotp-c0f1b4ebb0a532d90a1da18144dff7a645d83220.tar.gz
otp-c0f1b4ebb0a532d90a1da18144dff7a645d83220.tar.bz2
otp-c0f1b4ebb0a532d90a1da18144dff7a645d83220.zip
Merge branch 'ingela/inets/httpc-ipv6-brackets/OTP-15544' into maint
* ingela/inets/httpc-ipv6-brackets/OTP-15544: inets: httpc - Do not use bracked addresses to gen_tcp or ssl calls
Diffstat (limited to 'lib/inets')
-rw-r--r--lib/inets/src/http_client/httpc_handler.erl10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/inets/src/http_client/httpc_handler.erl b/lib/inets/src/http_client/httpc_handler.erl
index 1bf5d25c98..8b356d8026 100644
--- a/lib/inets/src/http_client/httpc_handler.erl
+++ b/lib/inets/src/http_client/httpc_handler.erl
@@ -805,11 +805,12 @@ handle_unix_socket_options(#request{unix_socket = UnixSocket},
error({badarg, [{ipfamily, Else}, {unix_socket, UnixSocket}]})
end.
-connect_and_send_first_request(Address, Request, #state{options = Options0} = State) ->
+connect_and_send_first_request(Address, #request{ipv6_host_with_brackets = HasBrackets} = Request,
+ #state{options = Options0} = State) ->
SocketType = socket_type(Request),
ConnTimeout = (Request#request.settings)#http_options.connect_timeout,
Options = handle_unix_socket_options(Request, Options0),
- case connect(SocketType, Address, Options, ConnTimeout) of
+ case connect(SocketType, format_address(Address, HasBrackets), Options, ConnTimeout) of
{ok, Socket} ->
ClientClose =
httpc_request:is_client_closing(
@@ -1739,3 +1740,8 @@ update_session(ProfileName, #session{id = SessionId} = Session, Pos, Value) ->
end.
+format_address({Host, Port}, true) when is_list(Host)->
+ {ok, Address} = inet:parse_address(string:strip(string:strip(Host, right, $]), left, $[)),
+ {Address, Port};
+format_address(HostPort, _) ->
+ HostPort.