diff options
author | Micael Karlberg <[email protected]> | 2011-10-12 11:37:32 +0200 |
---|---|---|
committer | Micael Karlberg <[email protected]> | 2011-10-12 11:37:32 +0200 |
commit | 45e501e1280839d91969e9d73449b9e474468e3e (patch) | |
tree | 8b410db4094d58a2e8b41423e3b6ce3c12eae146 | |
parent | d94c3259e06887bc0f333005f6955f5e75013b8e (diff) | |
download | otp-45e501e1280839d91969e9d73449b9e474468e3e.tar.gz otp-45e501e1280839d91969e9d73449b9e474468e3e.tar.bz2 otp-45e501e1280839d91969e9d73449b9e474468e3e.zip |
Make return from the parse function conform with:
{error, Reason} | {ok, ParsedURL}
-rw-r--r-- | lib/inets/src/http_client/httpc.erl | 6 | ||||
-rw-r--r-- | lib/inets/src/http_client/httpc_manager.erl | 6 | ||||
-rw-r--r-- | lib/inets/src/http_client/httpc_response.erl | 2 | ||||
-rw-r--r-- | lib/inets/src/http_lib/http_uri.erl | 6 |
4 files changed, 11 insertions, 9 deletions
diff --git a/lib/inets/src/http_client/httpc.erl b/lib/inets/src/http_client/httpc.erl index 75c26c63cc..6e566589aa 100644 --- a/lib/inets/src/http_client/httpc.erl +++ b/lib/inets/src/http_client/httpc.erl @@ -157,7 +157,7 @@ request(Method, {Url, Headers}, HTTPOptions, Options, Profile) case http_uri:parse(Url) of {error, Reason} -> {error, Reason}; - ParsedUrl -> + {ok, ParsedUrl} -> handle_request(Method, Url, ParsedUrl, Headers, [], [], HTTPOptions, Options, Profile) end; @@ -176,7 +176,7 @@ request(Method, {Url,Headers,ContentType,Body}, HTTPOptions, Options, Profile) case http_uri:parse(Url) of {error, Reason} -> {error, Reason}; - ParsedUrl -> + {ok, ParsedUrl} -> handle_request(Method, Url, ParsedUrl, Headers, ContentType, Body, HTTPOptions, Options, Profile) @@ -267,7 +267,7 @@ store_cookies(SetCookieHeaders, Url, Profile) {profile, Profile}]), try begin - {_, _, Host, Port, Path, _} = http_uri:parse(Url), + {ok, {_, _, Host, Port, Path, _}} = http_uri:parse(Url), Address = {Host, Port}, ProfileName = profile_name(Profile), Cookies = httpc_cookie:cookies(SetCookieHeaders, Path, Host), diff --git a/lib/inets/src/http_client/httpc_manager.erl b/lib/inets/src/http_client/httpc_manager.erl index 9015bf1ce2..470d802740 100644 --- a/lib/inets/src/http_client/httpc_manager.erl +++ b/lib/inets/src/http_client/httpc_manager.erl @@ -398,12 +398,12 @@ handle_call(which_cookies, _, #state{cookie_db = CookieDb} = State) -> handle_call({which_cookies, Url}, _, #state{cookie_db = CookieDb} = State) -> ?hcrv("which cookies", [{url, Url}]), case http_uri:parse(Url) of - {Scheme, _, Host, Port, Path, _} -> + {ok, {Scheme, _, Host, Port, Path, _}} -> CookieHeaders = httpc_cookie:header(CookieDb, Scheme, {Host, Port}, Path), {reply, CookieHeaders, State}; - Msg -> - {reply, Msg, State} + {error, _} = ERROR -> + {reply, ERROR, State} end; handle_call(info, _, State) -> diff --git a/lib/inets/src/http_client/httpc_response.erl b/lib/inets/src/http_client/httpc_response.erl index 207b96271c..4a2637a179 100644 --- a/lib/inets/src/http_client/httpc_response.erl +++ b/lib/inets/src/http_client/httpc_response.erl @@ -350,7 +350,7 @@ redirect(Response = {StatusLine, Headers, Body}, Request) -> {error, Reason} -> {ok, error(Request, Reason), Data}; %% Automatic redirection - {Scheme, _, Host, Port, Path, Query} -> + {ok, {Scheme, _, Host, Port, Path, Query}} -> NewHeaders = (Request#request.headers)#http_request_h{host = Host}, diff --git a/lib/inets/src/http_lib/http_uri.erl b/lib/inets/src/http_lib/http_uri.erl index 44b9face0b..5fa23ceb2d 100644 --- a/lib/inets/src/http_lib/http_uri.erl +++ b/lib/inets/src/http_lib/http_uri.erl @@ -16,7 +16,9 @@ %% %% %CopyrightEnd% %% -%% +%% +%% RFC 3986 +%% -module(http_uri). @@ -32,7 +34,7 @@ parse(AbsURI) -> {Scheme, Rest} -> case (catch parse_uri_rest(Scheme, Rest)) of {UserInfo, Host, Port, Path, Query} -> - {Scheme, UserInfo, Host, Port, Path, Query}; + {ok, {Scheme, UserInfo, Host, Port, Path, Query}}; _ -> {error, {malformed_url, AbsURI}} end |