.TH http_uri 3erl "inets 6.3.4" "Ericsson AB" "Erlang Module Definition" .SH NAME http_uri \- URI utility module .SH DESCRIPTION .LP This module provides utility functions for working with URIs, according to RFC 3986\&. .SH "DATA TYPES" .LP Type definitions that are used more than once in this module: .LP \fIboolean() = true | false\fR\& .LP \fIstring()\fR\& = list of ASCII characters .SH "URI DATA TYPES" .LP Type definitions that are related to URI: .RS 2 .TP 2 .B \fIuri() = string()\fR\&: Syntax according to the URI definition in RFC 3986, for example, "http://www\&.erlang\&.org/" .TP 2 .B \fIuser_info() = string()\fR\&: .TP 2 .B \fIscheme() = atom()\fR\&: Example: http, https .TP 2 .B \fIhost() = string()\fR\&: .TP 2 .B \fIport() = pos_integer()\fR\&: .TP 2 .B \fIpath() = string()\fR\&: Represents a file path or directory path .TP 2 .B \fIquery() = string()\fR\&: .TP 2 .B \fIfragment() = string()\fR\&: .RE .LP For more information about URI, see RFC 3986\&. .SH EXPORTS .LP .B decode(HexEncodedURI) -> URI .br .RS .LP Types: .RS 3 HexEncodedURI = string() - A possibly hexadecimal encoded URI .br URI = uri() .br .RE .RE .RS .LP Decodes a possibly hexadecimal encoded URI\&. .RE .LP .B encode(URI) -> HexEncodedURI .br .RS .LP Types: .RS 3 URI = uri() .br HexEncodedURI = string() - Hexadecimal encoded URI .br .RE .RE .RS .LP Encodes a hexadecimal encoded URI\&. .RE .LP .B parse(URI) -> {ok, Result} | {error, Reason} .br .B parse(URI, Options) -> {ok, Result} | {error, Reason} .br .RS .LP Types: .RS 3 URI = uri() .br Options = [Option] .br Option = {ipv6_host_with_brackets, boolean()} | {scheme_defaults, scheme_defaults()} | {fragment, boolean()} | {scheme_validation_fun, fun()}] .br Result = {Scheme, UserInfo, Host, Port, Path, Query} | {Scheme, UserInfo, Host, Port, Path, Query, Fragment} .br UserInfo = user_info() .br Host = host() .br Port = pos_integer() .br Path = path() .br Query = query() .br Fragment = fragment() .br Reason = term() .br .RE .RE .RS .LP Parses a URI\&. If no scheme defaults are provided, the value of the \fBscheme_defaults\fR\& function is used\&. .LP When parsing a URI with an unknown scheme (that is, a scheme not found in the scheme defaults), a port number must be provided, otherwise the parsing fails\&. .LP If the fragment option is \fItrue\fR\&, the URI fragment is returned as part of the parsing result, otherwise it is ignored\&. .LP Scheme validation fun is to be defined as follows: .LP .nf fun(SchemeStr :: string()) -> valid | {error, Reason :: term()}. .fi .LP It is called before scheme string gets converted into scheme atom and thus possible atom leak could be prevented .RE .LP .B scheme_defaults() -> SchemeDefaults .br .RS .LP Types: .RS 3 SchemeDefaults = [{scheme(), default_scheme_port_number()}] .br default_scheme_port_number() = pos_integer() .br .RE .RE .RS .LP Provides a list of the scheme and their default port numbers supported (by default) by this utility\&. .RE