diff options
author | Mikael Pettersson <mikael.pettersson@klarna.com> | 2019-10-29 13:44:50 +0100 |
---|---|---|
committer | Mikael Pettersson <mikael.pettersson@klarna.com> | 2019-10-29 13:44:50 +0100 |
commit | fad0123e4b97d4c9dd089ec1cb4a986dc7df2da0 (patch) | |
tree | d9fa2231743dac38b35f92e2f1e06c5f1e994256 /lib/inets | |
parent | 445fad5b5083356edc4ff064e0be5e720167f125 (diff) | |
download | erlang-fad0123e4b97d4c9dd089ec1cb4a986dc7df2da0.tar.gz |
httpc: do not pass error tuple to uri_string:parse/1
Diffstat (limited to 'lib/inets')
-rw-r--r-- | lib/inets/src/http_client/httpc.erl | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/inets/src/http_client/httpc.erl b/lib/inets/src/http_client/httpc.erl index 9967488f61..1e46fa955b 100644 --- a/lib/inets/src/http_client/httpc.erl +++ b/lib/inets/src/http_client/httpc.erl @@ -176,7 +176,7 @@ request(Method, (Method =:= delete) orelse (Method =:= trace) andalso (is_atom(Profile) orelse is_pid(Profile)) -> - case uri_string:parse(uri_string:normalize(Url)) of + case normalize_and_parse_url(Url) of {error, Reason, _} -> {error, Reason}; ParsedUrl -> @@ -190,7 +190,7 @@ request(Method, end. do_request(Method, {Url, Headers, ContentType, Body}, HTTPOptions, Options, Profile) -> - case uri_string:parse(uri_string:normalize(Url)) of + case normalize_and_parse_url(Url) of {error, Reason, _} -> {error, Reason}; ParsedUrl -> @@ -313,7 +313,7 @@ store_cookies(SetCookieHeaders, Url) -> store_cookies(SetCookieHeaders, Url, Profile) when is_atom(Profile) orelse is_pid(Profile) -> - case uri_string:parse(uri_string:normalize(Url)) of + case normalize_and_parse_url(Url) of {error, Bad, _} -> {error, {parse_failed, Bad}}; URI -> @@ -500,6 +500,12 @@ service_info(Pid) -> %%%======================================================================== %%% Internal functions %%%======================================================================== +normalize_and_parse_url(Url) -> + case uri_string:normalize(Url) of + {error, _, _} = Error -> Error; + UriString -> uri_string:parse(UriString) + end. + handle_request(Method, Url, URI, Headers0, ContentType, Body0, |