aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2011-04-18 13:32:35 +0200
committerLoïc Hoguin <[email protected]>2011-04-18 13:32:35 +0200
commit731d839323e74b95a326001e4e424a1f2b18902e (patch)
tree651bd6c94a3448ca46371d38b3899c88fcbb78b4
parentdb7833f5e8f407ad6f61eadc970966c35d030ead (diff)
downloadcowboy-731d839323e74b95a326001e4e424a1f2b18902e.tar.gz
cowboy-731d839323e74b95a326001e4e424a1f2b18902e.tar.bz2
cowboy-731d839323e74b95a326001e4e424a1f2b18902e.zip
Replace posix() by atom(), for now.
The type isn't exported by OTP so we don't win much. Also, inet.erl and file.erl define posix() différently, so OTP needs to stop being so confuse in the first place before we can attempt to use it properly.
-rw-r--r--include/types.hrl1
-rw-r--r--src/cowboy_http_req.erl4
-rw-r--r--src/cowboy_ssl_transport.erl16
-rw-r--r--src/cowboy_tcp_transport.erl14
4 files changed, 17 insertions, 18 deletions
diff --git a/include/types.hrl b/include/types.hrl
index 684ee03..371dd18 100644
--- a/include/types.hrl
+++ b/include/types.hrl
@@ -12,5 +12,4 @@
%% ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
%% OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
--type posix() :: atom().
-type port_number() :: 0..65535.
diff --git a/src/cowboy_http_req.erl b/src/cowboy_http_req.erl
index f8b54e4..932ba3e 100644
--- a/src/cowboy_http_req.erl
+++ b/src/cowboy_http_req.erl
@@ -145,7 +145,7 @@ headers(Req) ->
%% @todo We probably want to allow a max length.
-spec body(Req::#http_req{})
- -> {ok, Body::binary(), Req::#http_req{}} | {error, Reason::posix()}.
+ -> {ok, Body::binary(), Req::#http_req{}} | {error, Reason::atom()}.
body(Req) ->
{Length, Req2} = cowboy_http_req:header('Content-Length', Req),
case Length of
@@ -157,7 +157,7 @@ body(Req) ->
%% @todo We probably want to configure the timeout.
-spec body(Length::non_neg_integer(), Req::#http_req{})
- -> {ok, Body::binary(), Req::#http_req{}} | {error, Reason::posix()}.
+ -> {ok, Body::binary(), Req::#http_req{}} | {error, Reason::atom()}.
body(Length, Req=#http_req{socket=Socket, transport=Transport,
body_state=waiting}) ->
Transport:setopts(Socket, [{packet, raw}]),
diff --git a/src/cowboy_ssl_transport.erl b/src/cowboy_ssl_transport.erl
index 1a85f05..3909409 100644
--- a/src/cowboy_ssl_transport.erl
+++ b/src/cowboy_ssl_transport.erl
@@ -30,7 +30,7 @@ messages() -> {ssl, ssl_closed, ssl_error}.
-spec listen([{port, Port::port_number()} | {certfile, CertPath::string()}
| {keyfile, KeyPath::string()} | {password, Password::string()}])
- -> {ok, LSocket::sslsocket()} | {error, Reason::posix()}.
+ -> {ok, LSocket::sslsocket()} | {error, Reason::atom()}.
listen(Opts) ->
{port, Port} = lists:keyfind(port, 1, Opts),
{certfile, CertFile} = lists:keyfind(certfile, 1, Opts),
@@ -41,7 +41,7 @@ listen(Opts) ->
{certfile, CertFile}, {keyfile, KeyFile}, {password, Password}]).
-spec accept(LSocket::sslsocket(), Timeout::timeout())
- -> {ok, Socket::sslsocket()} | {error, Reason::closed | timeout | posix()}.
+ -> {ok, Socket::sslsocket()} | {error, Reason::closed | timeout | atom()}.
accept(LSocket, Timeout) ->
case ssl:transport_accept(LSocket, Timeout) of
{ok, CSocket} ->
@@ -51,27 +51,27 @@ accept(LSocket, Timeout) ->
end.
-spec recv(Socket::sslsocket(), Length::integer(), Timeout::timeout())
- -> {ok, Packet::term()} | {error, Reason::closed | posix()}.
+ -> {ok, Packet::term()} | {error, Reason::closed | atom()}.
recv(Socket, Length, Timeout) ->
ssl:recv(Socket, Length, Timeout).
-spec send(Socket::sslsocket(), Packet::iolist())
- -> ok | {error, Reason::posix()}.
+ -> ok | {error, Reason::atom()}.
send(Socket, Packet) ->
ssl:send(Socket, Packet).
-spec setopts(Socket::sslsocket(), Opts::list(term()))
- -> ok | {error, Reason::posix()}.
+ -> ok | {error, Reason::atom()}.
setopts(Socket, Opts) ->
ssl:setopts(Socket, Opts).
-spec controlling_process(Socket::sslsocket(), Pid::pid())
- -> ok | {error, Reason::closed | not_owner | posix()}.
+ -> ok | {error, Reason::closed | not_owner | atom()}.
controlling_process(Socket, Pid) ->
ssl:controlling_process(Socket, Pid).
-spec peername(Socket::sslsocket())
- -> {ok, {Address::inet:ip_address(), Port::port_number()}} | {error, posix()}.
+ -> {ok, {Address::inet:ip_address(), Port::port_number()}} | {error, atom()}.
peername(Socket) ->
ssl:peername(Socket).
@@ -82,7 +82,7 @@ close(Socket) ->
%% Internal.
-spec ssl_accept(CSocket::sslsocket(), Timeout::timeout())
- -> {ok, Socket::sslsocket()} | {error, Reason::closed | timeout | posix()}.
+ -> {ok, Socket::sslsocket()} | {error, Reason::closed | timeout | atom()}.
ssl_accept(CSocket, Timeout) ->
case ssl:ssl_accept(CSocket, Timeout) of
ok ->
diff --git a/src/cowboy_tcp_transport.erl b/src/cowboy_tcp_transport.erl
index 7ffd0b1..fa46451 100644
--- a/src/cowboy_tcp_transport.erl
+++ b/src/cowboy_tcp_transport.erl
@@ -27,7 +27,7 @@ name() -> tcp.
messages() -> {tcp, tcp_closed, tcp_error}.
-spec listen([{port, Port::port_number()}])
- -> {ok, LSocket::inet:socket()} | {error, Reason::posix()}.
+ -> {ok, LSocket::inet:socket()} | {error, Reason::atom()}.
listen(Opts) ->
{port, Port} = lists:keyfind(port, 1, Opts),
gen_tcp:listen(Port, [binary, {active, false},
@@ -35,32 +35,32 @@ listen(Opts) ->
-spec accept(LSocket::inet:socket(), Timeout::timeout())
-> {ok, Socket::inet:socket()}
- | {error, Reason::closed | timeout | posix()}.
+ | {error, Reason::closed | timeout | atom()}.
accept(LSocket, Timeout) ->
gen_tcp:accept(LSocket, Timeout).
-spec recv(Socket::inet:socket(), Length::integer(), Timeout::timeout())
- -> {ok, Packet::term()} | {error, Reason::closed | posix()}.
+ -> {ok, Packet::term()} | {error, Reason::closed | atom()}.
recv(Socket, Length, Timeout) ->
gen_tcp:recv(Socket, Length, Timeout).
-spec send(Socket::inet:socket(), Packet::iolist())
- -> ok | {error, Reason::posix()}.
+ -> ok | {error, Reason::atom()}.
send(Socket, Packet) ->
gen_tcp:send(Socket, Packet).
-spec setopts(Socket::inet:socket(), Opts::list(term()))
- -> ok | {error, Reason::posix()}.
+ -> ok | {error, Reason::atom()}.
setopts(Socket, Opts) ->
inet:setopts(Socket, Opts).
-spec controlling_process(Socket::inet:socket(), Pid::pid())
- -> ok | {error, Reason::closed | not_owner | posix()}.
+ -> ok | {error, Reason::closed | not_owner | atom()}.
controlling_process(Socket, Pid) ->
gen_tcp:controlling_process(Socket, Pid).
-spec peername(Socket::inet:socket())
- -> {ok, {Address::inet:ip_address(), Port::port_number()}} | {error, posix()}.
+ -> {ok, {Address::inet:ip_address(), Port::port_number()}} | {error, atom()}.
peername(Socket) ->
inet:peername(Socket).