Browse files

Improve typespecs

  • Loading branch information...
1 parent f3c5881 commit 76d6ed83ceb8dfd4b70336c24757b55cfad758f0 @essen essen committed Jul 24, 2012
Showing with 7 additions and 5 deletions.
  1. +4 −2 src/cowboy_http_req.erl
  2. +3 −3 src/cowboy_http_rest.erl
View
6 src/cowboy_http_req.erl
@@ -222,7 +222,8 @@ headers(Req) ->
%% returned is used as a return value.
%% @see parse_header/3
-spec parse_header(cowboy_http:header(), #http_req{})
- -> {any(), #http_req{}} | {error, badarg}.
+ -> {any(), #http_req{}} | {undefined, binary(), #http_req{}}
+ | {error, badarg}.
parse_header(Name, Req=#http_req{p_headers=PHeaders}) ->
case lists:keyfind(Name, 1, PHeaders) of
false -> parse_header(Name, Req, parse_header_default(Name));
@@ -239,7 +240,8 @@ parse_header_default(_Name) -> undefined.
%%
%% When the header is unknown, the value is returned directly without parsing.
-spec parse_header(cowboy_http:header(), #http_req{}, any())
- -> {any(), #http_req{}} | {error, badarg}.
+ -> {any(), #http_req{}} | {undefined, binary(), #http_req{}}
+ | {error, badarg}.
parse_header(Name, Req, Default) when Name =:= 'Accept' ->
parse_header(Name, Req, Default,
fun (Value) ->
View
6 src/cowboy_http_rest.erl
@@ -28,16 +28,16 @@
%% Media type.
content_types_p = [] ::
- [{{binary(), binary(), [{binary(), binary()}]}, atom()}],
+ [{binary() | {binary(), binary(), [{binary(), binary()}]}, atom()}],
content_type_a :: undefined
- | {{binary(), binary(), [{binary(), binary()}]}, atom()},
+ | {binary() | {binary(), binary(), [{binary(), binary()}]}, atom()},
%% Language.
languages_p = [] :: [binary()],
language_a :: undefined | binary(),
%% Charset.
- charsets_p = [] :: [binary()],
+ charsets_p = [] :: [{binary(), atom()}],
charset_a :: undefined | binary(),
%% Cached resource calls.

0 comments on commit 76d6ed8

Please sign in to comment.