diff options
author | Henrik Nord <[email protected]> | 2015-10-27 12:55:25 +0100 |
---|---|---|
committer | Henrik Nord <[email protected]> | 2015-10-27 12:55:25 +0100 |
commit | 1d6f49bfc5222217579540bd13c47a02e61896a9 (patch) | |
tree | 235b7e58fdfe6e99886c6367a5a23d7495aca0ec /lib/inets/src/http_lib/http_uri.erl | |
parent | 4b5853e7865d6a1baab39d7345b1b8d0280a4291 (diff) | |
parent | 7dc9eefa341fbfae0ebc55a88b96a375c611e3a4 (diff) | |
download | otp-1d6f49bfc5222217579540bd13c47a02e61896a9.tar.gz otp-1d6f49bfc5222217579540bd13c47a02e61896a9.tar.bz2 otp-1d6f49bfc5222217579540bd13c47a02e61896a9.zip |
Merge branch 'maint'
Diffstat (limited to 'lib/inets/src/http_lib/http_uri.erl')
-rw-r--r-- | lib/inets/src/http_lib/http_uri.erl | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/lib/inets/src/http_lib/http_uri.erl b/lib/inets/src/http_lib/http_uri.erl index 79591eec29..6fe8c1776d 100644 --- a/lib/inets/src/http_lib/http_uri.erl +++ b/lib/inets/src/http_lib/http_uri.erl @@ -138,16 +138,33 @@ parse_scheme(AbsURI, Opts) -> {error, no_scheme} -> {error, no_scheme}; {SchemeStr, Rest} -> - Scheme = list_to_atom(http_util:to_lower(SchemeStr)), - SchemeDefaults = which_scheme_defaults(Opts), - case lists:keysearch(Scheme, 1, SchemeDefaults) of - {value, {Scheme, DefaultPort}} -> - {Scheme, DefaultPort, Rest}; - false -> - {Scheme, no_default_port, Rest} + case extract_scheme(SchemeStr, Opts) of + {error, Error} -> + {error, Error}; + {ok, Scheme} -> + SchemeDefaults = which_scheme_defaults(Opts), + case lists:keysearch(Scheme, 1, SchemeDefaults) of + {value, {Scheme, DefaultPort}} -> + {Scheme, DefaultPort, Rest}; + false -> + {Scheme, no_default_port, Rest} + end end end. +extract_scheme(Str, Opts) -> + case lists:keysearch(scheme_validation_fun, 1, Opts) of + {value, {scheme_validation_fun, Fun}} when is_function(Fun) -> + case Fun(Str) of + valid -> + {ok, list_to_atom(http_util:to_lower(Str))}; + {error, Error} -> + {error, Error} + end; + _ -> + {ok, list_to_atom(http_util:to_lower(Str))} + end. + parse_uri_rest(Scheme, DefaultPort, "//" ++ URIPart, Opts) -> {Authority, PathQueryFragment} = split_uri(URIPart, "[/?#]", {URIPart, ""}, 1, 0), |