From 54ca9088b4a83b1f7dc22db7ec4c16607fdd8850 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Wed, 14 Mar 2012 18:09:12 +0100 Subject: [inets] Initial proposal of module http_uri MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This version of the module was provided by Johan Tjäder. It adds support for more methods (more than http and https). OTP-9983 --- lib/inets/src/http_lib/http_uri.erl | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'lib/inets/src/http_lib') diff --git a/lib/inets/src/http_lib/http_uri.erl b/lib/inets/src/http_lib/http_uri.erl index 32c6305a79..d0d1033cf6 100644 --- a/lib/inets/src/http_lib/http_uri.erl +++ b/lib/inets/src/http_lib/http_uri.erl @@ -72,12 +72,15 @@ parse_scheme(AbsURI) -> {error, no_scheme} -> {error, no_scheme}; {StrScheme, Rest} -> - case list_to_atom(http_util:to_lower(StrScheme)) of - Scheme when (Scheme =:= http) orelse (Scheme =:= https) -> - {Scheme, Rest}; - Scheme -> - {error, {not_supported_scheme, Scheme}} - end + %% case list_to_atom(http_util:to_lower(StrScheme)) of + %% Scheme when (Scheme =:= http) orelse (Scheme =:= https) -> + %% {Scheme, Rest}; + %% Scheme -> + %% {error, {not_supported_scheme, Scheme}} + %% end + + %% Allow all schemes even if they are unknown + {list_to_atom(http_util:to_lower(StrScheme)), Rest} end. parse_uri_rest(Scheme, "//" ++ URIPart, Opts) -> @@ -133,10 +136,21 @@ maybe_ipv6_host_with_brackets(Host, Opts) -> Host end. -default_port(http) -> +default_port(http) -> 80; -default_port(https) -> - 443. +default_port(https) -> + 443; + +%%% Added some additional default ports +%%% Other protocols would have to be handled by the calling function +default_port(ftp) -> 21; +default_port(ssh) -> 22; +default_port(sftp) -> 22; +default_port(tftp) -> 69; + +default_port(_) -> + undefined. + int_port(Port) when is_integer(Port) -> Port; -- cgit v1.2.3