Browse Source

Rename the type http_status/0 to cowboy_http:status/0

Loïc Hoguin 13 years ago
parent
commit
16d3cb76c7
4 changed files with 11 additions and 11 deletions
  1. 0 1
      include/http.hrl
  2. 2 1
      src/cowboy_http.erl
  3. 1 1
      src/cowboy_http_protocol.erl
  4. 8 8
      src/cowboy_http_req.erl

+ 0 - 1
include/http.hrl

@@ -13,7 +13,6 @@
 %% ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 %% ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 %% OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 %% OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 
--type http_status() :: non_neg_integer() | binary().
 -type http_resp_body() :: iodata() | {non_neg_integer(),
 -type http_resp_body() :: iodata() | {non_neg_integer(),
 		fun(() -> {sent, non_neg_integer()})}.
 		fun(() -> {sent, non_neg_integer()})}.
 
 

+ 2 - 1
src/cowboy_http.erl

@@ -47,8 +47,9 @@
 	| 'Set-Cookie2' | 'X-Forwarded-For' | 'Cookie' | 'Keep-Alive'
 	| 'Set-Cookie2' | 'X-Forwarded-For' | 'Cookie' | 'Keep-Alive'
 	| 'Proxy-Connection' | binary().
 	| 'Proxy-Connection' | binary().
 -type headers() :: [{header(), iodata()}].
 -type headers() :: [{header(), iodata()}].
+-type status() :: non_neg_integer() | binary().
 
 
--export_type([method/0, uri/0, version/0, header/0, headers/0]).
+-export_type([method/0, uri/0, version/0, header/0, headers/0, status/0]).
 
 
 -include("include/http.hrl").
 -include("include/http.hrl").
 -include_lib("eunit/include/eunit.hrl").
 -include_lib("eunit/include/eunit.hrl").

+ 1 - 1
src/cowboy_http_protocol.erl

@@ -403,7 +403,7 @@ ensure_response(#http_req{socket=Socket, transport=Transport,
 	close.
 	close.
 
 
 %% Only send an error reply if there is no resp_sent message.
 %% Only send an error reply if there is no resp_sent message.
--spec error_terminate(http_status(), #state{}) -> ok.
+-spec error_terminate(cowboy_http:status(), #state{}) -> ok.
 error_terminate(Code, State=#state{socket=Socket, transport=Transport}) ->
 error_terminate(Code, State=#state{socket=Socket, transport=Transport}) ->
 	receive
 	receive
 		{cowboy_http_req, resp_sent} -> ok
 		{cowboy_http_req, resp_sent} -> ok

+ 8 - 8
src/cowboy_http_req.erl

@@ -528,18 +528,18 @@ has_resp_body(#http_req{resp_body=RespBody}) ->
 	iolist_size(RespBody) > 0.
 	iolist_size(RespBody) > 0.
 
 
 %% @equiv reply(Status, [], [], Req)
 %% @equiv reply(Status, [], [], Req)
--spec reply(http_status(), #http_req{}) -> {ok, #http_req{}}.
+-spec reply(cowboy_http:status(), #http_req{}) -> {ok, #http_req{}}.
 reply(Status, Req=#http_req{resp_body=Body}) ->
 reply(Status, Req=#http_req{resp_body=Body}) ->
 	reply(Status, [], Body, Req).
 	reply(Status, [], Body, Req).
 
 
 %% @equiv reply(Status, Headers, [], Req)
 %% @equiv reply(Status, Headers, [], Req)
--spec reply(http_status(), cowboy_http:headers(), #http_req{})
+-spec reply(cowboy_http:status(), cowboy_http:headers(), #http_req{})
 	-> {ok, #http_req{}}.
 	-> {ok, #http_req{}}.
 reply(Status, Headers, Req=#http_req{resp_body=Body}) ->
 reply(Status, Headers, Req=#http_req{resp_body=Body}) ->
 	reply(Status, Headers, Body, Req).
 	reply(Status, Headers, Body, Req).
 
 
 %% @doc Send a reply to the client.
 %% @doc Send a reply to the client.
--spec reply(http_status(), cowboy_http:headers(), iodata(), #http_req{})
+-spec reply(cowboy_http:status(), cowboy_http:headers(), iodata(), #http_req{})
 	-> {ok, #http_req{}}.
 	-> {ok, #http_req{}}.
 reply(Status, Headers, Body, Req=#http_req{socket=Socket,
 reply(Status, Headers, Body, Req=#http_req{socket=Socket,
 		transport=Transport, connection=Connection, pid=ReqPid,
 		transport=Transport, connection=Connection, pid=ReqPid,
@@ -562,13 +562,13 @@ reply(Status, Headers, Body, Req=#http_req{socket=Socket,
 		resp_headers=[], resp_body= <<>>}}.
 		resp_headers=[], resp_body= <<>>}}.
 
 
 %% @equiv chunked_reply(Status, [], Req)
 %% @equiv chunked_reply(Status, [], Req)
--spec chunked_reply(http_status(), #http_req{}) -> {ok, #http_req{}}.
+-spec chunked_reply(cowboy_http:status(), #http_req{}) -> {ok, #http_req{}}.
 chunked_reply(Status, Req) ->
 chunked_reply(Status, Req) ->
 	chunked_reply(Status, [], Req).
 	chunked_reply(Status, [], Req).
 
 
 %% @doc Initiate the sending of a chunked reply to the client.
 %% @doc Initiate the sending of a chunked reply to the client.
 %% @see cowboy_http_req:chunk/2
 %% @see cowboy_http_req:chunk/2
--spec chunked_reply(http_status(), cowboy_http:headers(), #http_req{})
+-spec chunked_reply(cowboy_http:status(), cowboy_http:headers(), #http_req{})
 	-> {ok, #http_req{}}.
 	-> {ok, #http_req{}}.
 chunked_reply(Status, Headers, Req=#http_req{socket=Socket,
 chunked_reply(Status, Headers, Req=#http_req{socket=Socket,
 		transport=Transport, connection=Connection, pid=ReqPid,
 		transport=Transport, connection=Connection, pid=ReqPid,
@@ -597,7 +597,7 @@ chunk(Data, #http_req{socket=Socket, transport=Transport, resp_state=chunks}) ->
 
 
 %% @doc Send an upgrade reply.
 %% @doc Send an upgrade reply.
 %% @private
 %% @private
--spec upgrade_reply(http_status(), cowboy_http:headers(), #http_req{})
+-spec upgrade_reply(cowboy_http:status(), cowboy_http:headers(), #http_req{})
 	-> {ok, #http_req{}}.
 	-> {ok, #http_req{}}.
 upgrade_reply(Status, Headers, Req=#http_req{socket=Socket, transport=Transport,
 upgrade_reply(Status, Headers, Req=#http_req{socket=Socket, transport=Transport,
 		pid=ReqPid, resp_state=waiting, resp_headers=RespHeaders}) ->
 		pid=ReqPid, resp_state=waiting, resp_headers=RespHeaders}) ->
@@ -668,7 +668,7 @@ response_connection_parse(ReplyConn) ->
 	Tokens = cowboy_http:nonempty_list(ReplyConn, fun cowboy_http:token/2),
 	Tokens = cowboy_http:nonempty_list(ReplyConn, fun cowboy_http:token/2),
 	cowboy_http:connection_to_atom(Tokens).
 	cowboy_http:connection_to_atom(Tokens).
 
 
--spec response_head(http_status(), cowboy_http:headers(),
+-spec response_head(cowboy_http:status(), cowboy_http:headers(),
 	cowboy_http:headers(), cowboy_http:headers()) -> iolist().
 	cowboy_http:headers(), cowboy_http:headers()) -> iolist().
 response_head(Status, Headers, RespHeaders, DefaultHeaders) ->
 response_head(Status, Headers, RespHeaders, DefaultHeaders) ->
 	StatusLine = <<"HTTP/1.1 ", (status(Status))/binary, "\r\n">>,
 	StatusLine = <<"HTTP/1.1 ", (status(Status))/binary, "\r\n">>,
@@ -698,7 +698,7 @@ atom_to_connection(keepalive) ->
 atom_to_connection(close) ->
 atom_to_connection(close) ->
 	<<"close">>.
 	<<"close">>.
 
 
--spec status(http_status()) -> binary().
+-spec status(cowboy_http:status()) -> binary().
 status(100) -> <<"100 Continue">>;
 status(100) -> <<"100 Continue">>;
 status(101) -> <<"101 Switching Protocols">>;
 status(101) -> <<"101 Switching Protocols">>;
 status(102) -> <<"102 Processing">>;
 status(102) -> <<"102 Processing">>;