aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2012-03-14 18:09:12 +0100
committerMicael Karlberg <[email protected]>2012-03-14 18:09:12 +0100
commit54ca9088b4a83b1f7dc22db7ec4c16607fdd8850 (patch)
tree49ca8f1c3f41f87871a43802748c36a3c7601849
parent1017c9b5629148f3d584434f1c351cf1e8dded24 (diff)
downloadotp-54ca9088b4a83b1f7dc22db7ec4c16607fdd8850.tar.gz
otp-54ca9088b4a83b1f7dc22db7ec4c16607fdd8850.tar.bz2
otp-54ca9088b4a83b1f7dc22db7ec4c16607fdd8850.zip
[inets] Initial proposal of module http_uri
This version of the module was provided by Johan Tj�der. It adds support for more methods (more than http and https). OTP-9983
-rw-r--r--lib/inets/src/http_lib/http_uri.erl32
1 files changed, 23 insertions, 9 deletions
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;