aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cowboy.erl3
-rw-r--r--src/cowboy_handler.erl2
-rw-r--r--src/cowboy_http.erl4
-rw-r--r--src/cowboy_middleware.erl2
-rw-r--r--src/cowboy_protocol.erl6
-rw-r--r--src/cowboy_req.erl20
-rw-r--r--src/cowboy_sub_protocol.erl2
7 files changed, 19 insertions, 20 deletions
diff --git a/src/cowboy.erl b/src/cowboy.erl
index e2868a1..11a74c1 100644
--- a/src/cowboy.erl
+++ b/src/cowboy.erl
@@ -23,6 +23,9 @@
-type http_headers() :: [{binary(), iodata()}].
-export_type([http_headers/0]).
+-type http_status() :: non_neg_integer() | binary().
+-export_type([http_status/0]).
+
-type http_version() :: 'HTTP/1.1' | 'HTTP/1.0'.
-export_type([http_version/0]).
diff --git a/src/cowboy_handler.erl b/src/cowboy_handler.erl
index e040554..2074b4e 100644
--- a/src/cowboy_handler.erl
+++ b/src/cowboy_handler.erl
@@ -105,7 +105,7 @@ handler_init(Req, State, Handler, HandlerOpts) ->
-> {ok, Req, Env}
| {suspend, module(), atom(), any()}
| {halt, Req}
- | {error, cowboy_http:status(), Req}
+ | {error, cowboy:http_status(), Req}
when Req::cowboy_req:req(), Env::cowboy_middleware:env().
upgrade_protocol(Req, #state{env=Env},
Handler, HandlerOpts, Module) ->
diff --git a/src/cowboy_http.erl b/src/cowboy_http.erl
index 8dbbcff..af60dd9 100644
--- a/src/cowboy_http.erl
+++ b/src/cowboy_http.erl
@@ -52,10 +52,6 @@
-export([urlencode/2]).
-export([x_www_form_urlencoded/1]).
--type status() :: non_neg_integer() | binary().
-
--export_type([status/0]).
-
%% Parsing.
%% @doc Parse a non-empty list of the given type.
diff --git a/src/cowboy_middleware.erl b/src/cowboy_middleware.erl
index 3d58627..40c9407 100644
--- a/src/cowboy_middleware.erl
+++ b/src/cowboy_middleware.erl
@@ -32,5 +32,5 @@
-> {ok, Req, Env}
| {suspend, module(), atom(), [any()]}
| {halt, Req}
- | {error, cowboy_http:status(), Req}
+ | {error, cowboy:http_status(), Req}
when Req::cowboy_req:req(), Env::env().
diff --git a/src/cowboy_protocol.erl b/src/cowboy_protocol.erl
index 41a3c06..0bcf5a1 100644
--- a/src/cowboy_protocol.erl
+++ b/src/cowboy_protocol.erl
@@ -58,7 +58,7 @@
-type onrequest_fun() :: fun((Req) -> Req).
-type onresponse_fun() ::
- fun((cowboy_http:status(), cowboy:http_headers(), iodata(), Req) -> Req).
+ fun((cowboy:http_status(), cowboy:http_headers(), iodata(), Req) -> Req).
-export_type([onrequest_fun/0]).
-export_type([onresponse_fun/0]).
@@ -565,7 +565,7 @@ next_request(Req, State=#state{req_keepalive=Keepalive, timeout=Timeout},
end.
%% Only send an error reply if there is no resp_sent message.
--spec error_terminate(cowboy_http:status(), cowboy_req:req(), #state{}) -> ok.
+-spec error_terminate(cowboy:http_status(), cowboy_req:req(), #state{}) -> ok.
error_terminate(Code, Req, State) ->
receive
{cowboy_req, resp_sent} -> ok
@@ -576,7 +576,7 @@ error_terminate(Code, Req, State) ->
terminate(State).
%% Only send an error reply if there is no resp_sent message.
--spec error_terminate(cowboy_http:status(), #state{}) -> ok.
+-spec error_terminate(cowboy:http_status(), #state{}) -> ok.
error_terminate(Code, State=#state{socket=Socket, transport=Transport,
compress=Compress, onresponse=OnResponse}) ->
receive
diff --git a/src/cowboy_req.erl b/src/cowboy_req.erl
index 2e654bf..e522907 100644
--- a/src/cowboy_req.erl
+++ b/src/cowboy_req.erl
@@ -925,18 +925,18 @@ delete_resp_header(Name, Req=#http_req{resp_headers=RespHeaders}) ->
Req#http_req{resp_headers=RespHeaders2}.
%% @equiv reply(Status, [], [], Req)
--spec reply(cowboy_http:status(), Req) -> {ok, Req} when Req::req().
+-spec reply(cowboy:http_status(), Req) -> {ok, Req} when Req::req().
reply(Status, Req=#http_req{resp_body=Body}) ->
reply(Status, [], Body, Req).
%% @equiv reply(Status, Headers, [], Req)
--spec reply(cowboy_http:status(), cowboy:http_headers(), Req)
+-spec reply(cowboy:http_status(), cowboy:http_headers(), Req)
-> {ok, Req} when Req::req().
reply(Status, Headers, Req=#http_req{resp_body=Body}) ->
reply(Status, Headers, Body, Req).
%% @doc Send a reply to the client.
--spec reply(cowboy_http:status(), cowboy:http_headers(),
+-spec reply(cowboy:http_status(), cowboy:http_headers(),
iodata() | {non_neg_integer() | resp_body_fun()}, Req)
-> {ok, Req} when Req::req().
reply(Status, Headers, Body, Req=#http_req{
@@ -1047,13 +1047,13 @@ reply_no_compress(Status, Headers, Body, Req,
Req2.
%% @equiv chunked_reply(Status, [], Req)
--spec chunked_reply(cowboy_http:status(), Req) -> {ok, Req} when Req::req().
+-spec chunked_reply(cowboy:http_status(), Req) -> {ok, Req} when Req::req().
chunked_reply(Status, Req) ->
chunked_reply(Status, [], Req).
%% @doc Initiate the sending of a chunked reply to the client.
%% @see cowboy_req:chunk/2
--spec chunked_reply(cowboy_http:status(), cowboy:http_headers(), Req)
+-spec chunked_reply(cowboy:http_status(), cowboy:http_headers(), Req)
-> {ok, Req} when Req::req().
chunked_reply(Status, Headers, Req) ->
{_, Req2} = chunked_response(Status, Headers, Req),
@@ -1073,7 +1073,7 @@ chunk(Data, #http_req{socket=Socket, transport=Transport, resp_state=chunks}) ->
%% @doc Send an upgrade reply.
%% @private
--spec upgrade_reply(cowboy_http:status(), cowboy:http_headers(), Req)
+-spec upgrade_reply(cowboy:http_status(), cowboy:http_headers(), Req)
-> {ok, Req} when Req::req().
upgrade_reply(Status, Headers, Req=#http_req{
resp_state=waiting, resp_headers=RespHeaders}) ->
@@ -1084,7 +1084,7 @@ upgrade_reply(Status, Headers, Req=#http_req{
%% @doc Ensure the response has been sent fully.
%% @private
--spec ensure_response(req(), cowboy_http:status()) -> ok.
+-spec ensure_response(req(), cowboy:http_status()) -> ok.
%% The response has already been fully sent to the client.
ensure_response(#http_req{resp_state=done}, _) ->
ok;
@@ -1210,7 +1210,7 @@ to_list(Req) ->
%% Internal.
--spec chunked_response(cowboy_http:status(), cowboy:http_headers(), Req) ->
+-spec chunked_response(cowboy:http_status(), cowboy:http_headers(), Req) ->
{normal | hook, Req} when Req::req().
chunked_response(Status, Headers, Req=#http_req{
version=Version, connection=Connection,
@@ -1229,7 +1229,7 @@ chunked_response(Status, Headers, Req=#http_req{
{RespType, Req2#http_req{connection=RespConn, resp_state=chunks,
resp_headers=[], resp_body= <<>>}}.
--spec response(cowboy_http:status(), cowboy:http_headers(),
+-spec response(cowboy:http_status(), cowboy:http_headers(),
cowboy:http_headers(), cowboy:http_headers(), iodata(), Req)
-> {normal | hook, Req} when Req::req().
response(Status, Headers, RespHeaders, DefaultHeaders, Body, Req=#http_req{
@@ -1371,7 +1371,7 @@ connection_to_atom([<<"close">>|_]) ->
connection_to_atom([_|Tail]) ->
connection_to_atom(Tail).
--spec status(cowboy_http:status()) -> binary().
+-spec status(cowboy:http_status()) -> binary().
status(100) -> <<"100 Continue">>;
status(101) -> <<"101 Switching Protocols">>;
status(102) -> <<"102 Processing">>;
diff --git a/src/cowboy_sub_protocol.erl b/src/cowboy_sub_protocol.erl
index babc6f2..26ccd7e 100644
--- a/src/cowboy_sub_protocol.erl
+++ b/src/cowboy_sub_protocol.erl
@@ -33,5 +33,5 @@
-> {ok, Req, Env}
| {suspend, module(), atom(), [any()]}
| {halt, Req}
- | {error, cowboy_http:status(), Req}
+ | {error, cowboy:http_status(), Req}
when Req::cowboy_req:req(), Env::cowboy_middleware:env().