File 0600-httpc-do-not-pass-error-tuple-to-uri_string-parse-1.patch of Package erlang
From fad0123e4b97d4c9dd089ec1cb4a986dc7df2da0 Mon Sep 17 00:00:00 2001
From: Mikael Pettersson <mikael.pettersson@klarna.com>
Date: Tue, 29 Oct 2019 13:44:50 +0100
Subject: [PATCH 1/2] httpc: do not pass error tuple to uri_string:parse/1
---
lib/inets/src/http_client/httpc.erl | 12 +++++++++---
1 file 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,
--
2.16.4