aboutsummaryrefslogtreecommitdiffstats
path: root/lib/inets/src
diff options
context:
space:
mode:
authorPéter Dimitrov <[email protected]>2018-07-09 10:07:03 +0200
committerGitHub <[email protected]>2018-07-09 10:07:03 +0200
commitd6df0f288852e460ed3fc4475bb3dcb0065e2d61 (patch)
tree3f395751a45cd535b4e94ef0b0753e7d83582090 /lib/inets/src
parent0a6963fcc4a077a7b51669178271dc4ae4d7d3cb (diff)
parent3291b50bb2115008834b8ce0aa2521b1a4a04bc8 (diff)
downloadotp-d6df0f288852e460ed3fc4475bb3dcb0065e2d61.tar.gz
otp-d6df0f288852e460ed3fc4475bb3dcb0065e2d61.tar.bz2
otp-d6df0f288852e460ed3fc4475bb3dcb0065e2d61.zip
Merge pull request #1862 from rschlaikjer/rschlaikjer-httpc-ssl-redirect-bug
httpc 301 redirect: Do not assert scheme ports are equal
Diffstat (limited to 'lib/inets/src')
-rw-r--r--lib/inets/src/http_client/httpc_response.erl31
1 files changed, 15 insertions, 16 deletions
diff --git a/lib/inets/src/http_client/httpc_response.erl b/lib/inets/src/http_client/httpc_response.erl
index 0f3bd0a06d..78d6b4ed24 100644
--- a/lib/inets/src/http_client/httpc_response.erl
+++ b/lib/inets/src/http_client/httpc_response.erl
@@ -423,23 +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 ->
- Port = 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 => Port,
- path => maps:get(path, URI)},
- URI);
- false ->
- Map = Map0#{scheme => Scheme},
- resolve_authority(Host, Port, Path, Query, URI, 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);
@@ -457,15 +458,13 @@ get_default_port("https") ->
resolve_authority(Host, Port, Path, Query, RelURI, Map) ->
case maps:is_key(host, RelURI) of
true ->
- Port = get_port(RelURI),
maybe_add_query(
Map#{host => maps:get(host, RelURI),
- port => Port,
path => maps:get(path, RelURI)},
RelURI);
false ->
Map1 = Map#{host => Host,
- port => Port},
+ port => Port},
resolve_path(Path, Query, RelURI, Map1)
end.