tcp_port() -> inet:port_number(), addressing #4

This commit is contained in:
Gavin M. Roy 2018-04-06 13:29:33 -04:00
parent 87c36905b5
commit 92da14e9d8
2 changed files with 6 additions and 9 deletions

View file

@ -33,13 +33,12 @@ Type | Definition
`password()` | `string() | undefined`
`userinfo()` | `{username(), password()} | undefined`
`host()` | `string()`
`tcp_port()` | `integer()`
`authority()` | `{userinfo(), host(), tcp_port()}`
`authority()` | `{userinfo(), host(), inet:port_number()}`
`path()` | `string()`
`query()` | `[tuple() | string()] | undefined`
`fragment()` | `string() | undefined`
`uri()` | `{scheme(), authority(), path(), query(), fragment()}`
`url()` | `{scheme(), username(), password(), host(), tcp_port(), path(), query(), fragment()}`
`url()` | `{scheme(), username(), password(), host(), inet:port_number(), path(), query(), fragment()}`
## Example Usage
@ -48,7 +47,7 @@ Eshell V7.2.1 (abort with ^G)
1> urilib:build({http, {{"guest", "guest"}, "localhost", 15672}, "/api/queues", [{"name", "test"}], undefined}).
"http://guest:guest@localhost:15672/api/queues?name=test"
2> urilib:build({http, "guest", "guest", "localhost", 15672, "/api/queues", [{"name", "test"}], undefined}).
2> urilib:build({http, "guest", "guest", "localhost", 15672, "/api/queues", [{"name", "test"}], undefined}).
"http://guest:guest@localhost:15672/api/queues?name=test"
3> urilib:parse("http://guest:guest@localhost:15672/api/queues?name=test").

View file

@ -18,7 +18,6 @@
-export_type([scheme/0,
host/0,
tcp_port/0,
username/0,
password/0,
userinfo/0,
@ -37,16 +36,15 @@
-type hexcase() :: uppercase | lowercase.
-type scheme() :: http | https | atom().
-type host() :: string().
-type tcp_port() :: integer().
-type username() :: string() | undefined.
-type password() :: string() | undefined.
-type userinfo() :: {username(), password()} | undefined.
-type authority() :: {userinfo(), host(), tcp_port()}.
-type authority() :: {userinfo(), host(), inet:port_number()}.
-type path() :: string().
-type query() :: [tuple() | string()] | undefined.
-type fragment() :: string() | undefined.
-type uri() :: {scheme(), authority(), path(), query(), fragment()}.
-type url() :: {scheme(), username(), password(), host(), tcp_port(), path(), query(), fragment()}.
-type url() :: {scheme(), username(), password(), host(), inet:port_number(), path(), query(), fragment()}.
-spec build(Value :: uri() | url()) -> string().
%% @doc Build a URI
@ -247,7 +245,7 @@ url_maybe_add_userinfo(Username, Password, URL) ->
string:concat(URL, string:concat(string:join([Username, Password], ":"), "@")).
-spec url_add_host_and_port(scheme(), host(), tcp_port(), string()) -> string().
-spec url_add_host_and_port(scheme(), host(), inet:port_number(), string()) -> string().
%% @private
url_add_host_and_port(undefined, Host, undefined, URL) ->
string:concat(URL, Host);