mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 12:20:24 +00:00
Replace port_number() by ip_port() from kernel/include/inet.hrl.
This commit is contained in:
parent
731d839323
commit
63a92df14e
5 changed files with 10 additions and 8 deletions
|
@ -12,6 +12,8 @@
|
|||
%% ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
%% OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
-include_lib("kernel/include/inet.hrl").
|
||||
|
||||
-type http_method() :: 'OPTIONS' | 'GET' | 'HEAD'
|
||||
| 'POST' | 'PUT' | 'DELETE' | 'TRACE' | string().
|
||||
-type http_uri() :: '*' | {absoluteURI, http | https, Host::string(),
|
||||
|
@ -45,7 +47,7 @@
|
|||
%% Request.
|
||||
method = 'GET' :: http_method(),
|
||||
version = {1, 1} :: http_version(),
|
||||
peer = undefined :: undefined | {Address::inet:ip_address(), Port::port_number()},
|
||||
peer = undefined :: undefined | {Address::ip_address(), Port::ip_port()},
|
||||
host = undefined :: undefined | cowboy_dispatcher:path_tokens(),
|
||||
raw_host = undefined :: undefined | string(),
|
||||
path = undefined :: undefined | '*' | cowboy_dispatcher:path_tokens(),
|
||||
|
|
|
@ -11,5 +11,3 @@
|
|||
%% WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
%% ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
%% OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
-type port_number() :: 0..65535.
|
||||
|
|
|
@ -48,7 +48,7 @@ version(Req) ->
|
|||
{Req#http_req.version, Req}.
|
||||
|
||||
-spec peer(Req::#http_req{})
|
||||
-> {{Address::inet:ip_address(), Port::port_number()}, Req::#http_req{}}.
|
||||
-> {{Address::ip_address(), Port::ip_port()}, Req::#http_req{}}.
|
||||
peer(Req=#http_req{socket=Socket, transport=Transport, peer=undefined}) ->
|
||||
{ok, Peer} = Transport:peername(Socket),
|
||||
{Peer, Req#http_req{peer=Peer}};
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
-opaque sslsocket() :: term().
|
||||
|
||||
-include("include/types.hrl").
|
||||
-include_lib("kernel/include/inet.hrl").
|
||||
|
||||
%% API.
|
||||
|
||||
|
@ -28,7 +29,7 @@ name() -> ssl.
|
|||
-spec messages() -> {ssl, ssl_closed, ssl_error}.
|
||||
messages() -> {ssl, ssl_closed, ssl_error}.
|
||||
|
||||
-spec listen([{port, Port::port_number()} | {certfile, CertPath::string()}
|
||||
-spec listen([{port, Port::ip_port()} | {certfile, CertPath::string()}
|
||||
| {keyfile, KeyPath::string()} | {password, Password::string()}])
|
||||
-> {ok, LSocket::sslsocket()} | {error, Reason::atom()}.
|
||||
listen(Opts) ->
|
||||
|
@ -71,7 +72,7 @@ controlling_process(Socket, Pid) ->
|
|||
ssl:controlling_process(Socket, Pid).
|
||||
|
||||
-spec peername(Socket::sslsocket())
|
||||
-> {ok, {Address::inet:ip_address(), Port::port_number()}} | {error, atom()}.
|
||||
-> {ok, {Address::ip_address(), Port::ip_port()}} | {error, atom()}.
|
||||
peername(Socket) ->
|
||||
ssl:peername(Socket).
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
controlling_process/2, peername/1, close/1]). %% API.
|
||||
|
||||
-include("include/types.hrl").
|
||||
-include_lib("kernel/include/inet.hrl").
|
||||
|
||||
%% API.
|
||||
|
||||
|
@ -26,7 +27,7 @@ name() -> tcp.
|
|||
-spec messages() -> {tcp, tcp_closed, tcp_error}.
|
||||
messages() -> {tcp, tcp_closed, tcp_error}.
|
||||
|
||||
-spec listen([{port, Port::port_number()}])
|
||||
-spec listen([{port, Port::ip_port()}])
|
||||
-> {ok, LSocket::inet:socket()} | {error, Reason::atom()}.
|
||||
listen(Opts) ->
|
||||
{port, Port} = lists:keyfind(port, 1, Opts),
|
||||
|
@ -60,7 +61,7 @@ controlling_process(Socket, Pid) ->
|
|||
gen_tcp:controlling_process(Socket, Pid).
|
||||
|
||||
-spec peername(Socket::inet:socket())
|
||||
-> {ok, {Address::inet:ip_address(), Port::port_number()}} | {error, atom()}.
|
||||
-> {ok, {Address::ip_address(), Port::ip_port()}} | {error, atom()}.
|
||||
peername(Socket) ->
|
||||
inet:peername(Socket).
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue