From 9f4016748782876c4ac006a438df52a6bf19203c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 23 Jan 2012 09:21:33 +0100 Subject: Rename the type http_method/0 to cowboy_http:method/0 Exported types are much better than include files. --- include/http.hrl | 4 +--- src/cowboy_http.erl | 5 +++++ src/cowboy_http_protocol.erl | 2 +- src/cowboy_http_req.erl | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/include/http.hrl b/include/http.hrl index a10b120..c693e53 100644 --- a/include/http.hrl +++ b/include/http.hrl @@ -13,8 +13,6 @@ %% ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF %% OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --type http_method() :: 'OPTIONS' | 'GET' | 'HEAD' - | 'POST' | 'PUT' | 'DELETE' | 'TRACE' | binary(). -type http_uri() :: '*' | {absoluteURI, http | https, Host::binary(), Port::integer() | undefined, Path::binary()} | {scheme, Scheme::binary(), binary()} @@ -47,7 +45,7 @@ %% Request. pid = undefined :: pid(), - method = 'GET' :: http_method(), + method = 'GET' :: cowboy_http:method(), version = {1, 1} :: http_version(), peer = undefined :: undefined | {inet:ip_address(), inet:ip_port()}, host = undefined :: undefined | cowboy_dispatcher:tokens(), diff --git a/src/cowboy_http.erl b/src/cowboy_http.erl index 7c1a2d3..2f29375 100644 --- a/src/cowboy_http.erl +++ b/src/cowboy_http.erl @@ -26,6 +26,11 @@ -export([connection_to_atom/1, urldecode/1, urldecode/2, urlencode/1, urlencode/2]). +-type method() :: 'OPTIONS' | 'GET' | 'HEAD' + | 'POST' | 'PUT' | 'DELETE' | 'TRACE' | binary(). + +-export_type([method/0]). + -include("include/http.hrl"). -include_lib("eunit/include/eunit.hrl"). diff --git a/src/cowboy_http_protocol.erl b/src/cowboy_http_protocol.erl index cd951d1..1202dbe 100644 --- a/src/cowboy_http_protocol.erl +++ b/src/cowboy_http_protocol.erl @@ -108,7 +108,7 @@ wait_request(State=#state{socket=Socket, transport=Transport, {error, _Reason} -> terminate(State) end. --spec request({http_request, http_method(), http_uri(), +-spec request({http_request, cowboy_http:method(), http_uri(), http_version()}, #state{}) -> ok | none(). request({http_request, _Method, _URI, Version}, State) when Version =/= {1, 0}, Version =/= {1, 1} -> diff --git a/src/cowboy_http_req.erl b/src/cowboy_http_req.erl index aa30d2c..520dab8 100644 --- a/src/cowboy_http_req.erl +++ b/src/cowboy_http_req.erl @@ -56,7 +56,7 @@ %% Request API. %% @doc Return the HTTP method of the request. --spec method(#http_req{}) -> {http_method(), #http_req{}}. +-spec method(#http_req{}) -> {cowboy_http:method(), #http_req{}}. method(Req) -> {Req#http_req.method, Req}. -- cgit v1.2.3