diff options
author | Péter Dimitrov <[email protected]> | 2018-07-04 15:55:35 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2018-07-04 15:55:35 +0200 |
commit | 26f54151e90abc901a5e58dfc72110925b42522c (patch) | |
tree | a5c980c810b2d8854c6a8213f90b450ba54265d8 | |
parent | a65777d6e18fbb3c3de0fcc0753cce43c0bc40b6 (diff) | |
parent | 3292db3fdb6cf50852301b337999bafd17d41816 (diff) | |
download | otp-26f54151e90abc901a5e58dfc72110925b42522c.tar.gz otp-26f54151e90abc901a5e58dfc72110925b42522c.tar.bz2 otp-26f54151e90abc901a5e58dfc72110925b42522c.zip |
Merge pull request #1859 from josevalim/patch-9
Include question mark in query string on redirect
-rw-r--r-- | lib/inets/src/http_client/httpc_response.erl | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/inets/src/http_client/httpc_response.erl b/lib/inets/src/http_client/httpc_response.erl index 0f3bd0a06d..1af85f8fe0 100644 --- a/lib/inets/src/http_client/httpc_response.erl +++ b/lib/inets/src/http_client/httpc_response.erl @@ -398,7 +398,7 @@ redirect(Response = {_, Headers, _}, Request) -> THost = http_util:maybe_add_brackets(maps:get(host, URIMap), Brackets), TPort = maps:get(port, URIMap), TPath = maps:get(path, URIMap), - TQuery = maps:get(query, URIMap, ""), + TQuery = add_question_mark(maps:get(query, URIMap, "")), NewURI = uri_string:normalize( uri_string:recompose(URIMap)), HostPort = http_request:normalize_host(TScheme, THost, TPort), @@ -417,6 +417,14 @@ redirect(Response = {_, Headers, _}, Request) -> end end. +add_question_mark(<<>>) -> + <<>>; +add_question_mark([]) -> + []; +add_question_mark(Comp) when is_binary(Comp) -> + <<$?, Comp/binary>>; +add_question_mark(Comp) when is_list(Comp) -> + [$?|Comp]. %% RFC3986 - 5.2.2. Transform References resolve_uri(Scheme, Host, Port, Path, Query, URI) -> |