aboutsummaryrefslogtreecommitdiffstats
path: root/lib/inets/src
diff options
context:
space:
mode:
authorRoss Schlaikjer <[email protected]>2018-07-04 08:13:20 -0400
committerRoss Schlaikjer <[email protected]>2018-07-06 08:46:30 -0400
commit3291b50bb2115008834b8ce0aa2521b1a4a04bc8 (patch)
tree6201ee9e402a7f54799c530062f93afe3c3f41cd /lib/inets/src
parentcf43aba758ceeb1e4f313a2fdc1e901b9c1be06a (diff)
downloadotp-3291b50bb2115008834b8ce0aa2521b1a4a04bc8.tar.gz
otp-3291b50bb2115008834b8ce0aa2521b1a4a04bc8.tar.bz2
otp-3291b50bb2115008834b8ce0aa2521b1a4a04bc8.zip
Don't modify URI, explicitly pass scheme to get_port
Diffstat (limited to 'lib/inets/src')
-rw-r--r--lib/inets/src/http_client/httpc_response.erl32
1 files changed, 15 insertions, 17 deletions
diff --git a/lib/inets/src/http_client/httpc_response.erl b/lib/inets/src/http_client/httpc_response.erl
index 46073d47ec..78d6b4ed24 100644
--- a/lib/inets/src/http_client/httpc_response.erl
+++ b/lib/inets/src/http_client/httpc_response.erl
@@ -423,24 +423,24 @@ resolve_uri(Scheme, Host, Port, Path, Query, URI) ->
resolve_uri(Scheme, Host, Port, Path, Query, URI, #{}).
%%
resolve_uri(Scheme, Host, Port, Path, Query, URI, Map0) ->
- case maps:is_key(scheme, URI) of
- true ->
- Port0 = get_port(URI),
+ case maps:get(scheme, URI, undefined) of
+ undefined ->
+ Port0 = get_port(Scheme, URI),
+ Map = Map0#{scheme => Scheme,
+ port => Port0},
+ resolve_authority(Host, Port, Path, Query, URI, Map);
+ URIScheme ->
+ Port0 = get_port(URIScheme, URI),
maybe_add_query(
- Map0#{scheme => maps:get(scheme, URI),
- host => maps:get(host, URI),
- port => Port0,
- path => maps:get(path, URI)},
- URI);
- false ->
- Map = Map0#{scheme => Scheme},
- URI1 = URI#{scheme => Scheme},
- resolve_authority(Host, Port, Path, Query, URI1, Map)
+ Map0#{scheme => URIScheme,
+ host => maps:get(host, URI),
+ port => Port0,
+ path => maps:get(path, URI)},
+ URI)
end.
-get_port(URI) ->
- Scheme = maps:get(scheme, URI),
+get_port(Scheme, URI) ->
case maps:get(port, URI, undefined) of
undefined ->
get_default_port(Scheme);
@@ -458,15 +458,13 @@ get_default_port("https") ->
resolve_authority(Host, Port, Path, Query, RelURI, Map) ->
case maps:is_key(host, RelURI) of
true ->
- Port0 = get_port(RelURI),
maybe_add_query(
Map#{host => maps:get(host, RelURI),
- port => Port0,
path => maps:get(path, RelURI)},
RelURI);
false ->
Map1 = Map#{host => Host,
- port => Port},
+ port => Port},
resolve_path(Path, Query, RelURI, Map1)
end.