aboutsummaryrefslogtreecommitdiffstats
path: root/lib/inets/src
diff options
context:
space:
mode:
authorPéter Dimitrov <[email protected]>2018-07-09 10:20:27 +0200
committerPéter Dimitrov <[email protected]>2018-07-09 10:20:27 +0200
commit177a3470d598c892e0b7251cd2d9219aebcd3747 (patch)
treec012738cca4cc2695307d9b3b61f0f0dd91d0b9a /lib/inets/src
parentaeea56792ca19f78bff65cd8300b3e5b0b041d55 (diff)
parentd6df0f288852e460ed3fc4475bb3dcb0065e2d61 (diff)
downloadotp-177a3470d598c892e0b7251cd2d9219aebcd3747.tar.gz
otp-177a3470d598c892e0b7251cd2d9219aebcd3747.tar.bz2
otp-177a3470d598c892e0b7251cd2d9219aebcd3747.zip
Merge branch 'maint'
* maint: Don't modify URI, explicitly pass scheme to get_port Update scheme on redirect URI and accumulator Fix accidental Port assertion in resolve_authority Add test case on relative redirects with ports Do not assert that new URI port is same as old port Add mixed test group, http -> https redirect test Change-Id: I23b976dbc64e19787d6eca5757df50a1b7098857
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 1af85f8fe0..bb6b76da89 100644
--- a/lib/inets/src/http_client/httpc_response.erl
+++ b/lib/inets/src/http_client/httpc_response.erl
@@ -431,23 +431,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);
@@ -465,15 +466,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.