aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2012-10-11 20:03:34 +0200
committerLoïc Hoguin <[email protected]>2012-10-11 20:03:34 +0200
commit9facad92459d7277fd7ba510fc769d95a0498fab (patch)
treedbda4216e8133b99d7d7e5b42ad17c3dbcb1000d
parent1f9d71c3f5cbc2887a6f1362f5b8cd9b52b21390 (diff)
downloadcowboy-9facad92459d7277fd7ba510fc769d95a0498fab.tar.gz
cowboy-9facad92459d7277fd7ba510fc769d95a0498fab.tar.bz2
cowboy-9facad92459d7277fd7ba510fc769d95a0498fab.zip
Cleanup cowboy_req:parse_header/3
As suggested by @yrashk.
-rw-r--r--src/cowboy_req.erl21
1 files changed, 4 insertions, 17 deletions
diff --git a/src/cowboy_req.erl b/src/cowboy_req.erl
index 5b8cb7e..67d2a0f 100644
--- a/src/cowboy_req.erl
+++ b/src/cowboy_req.erl
@@ -399,7 +399,6 @@ parse_header(Name, Req=#http_req{p_headers=PHeaders}) ->
%% @doc Default values for semantic header parsing.
-spec parse_header_default(binary()) -> any().
-parse_header_default(<<"connection">>) -> [];
parse_header_default(<<"transfer-encoding">>) -> [<<"identity">>];
parse_header_default(_Name) -> undefined.
@@ -430,15 +429,9 @@ parse_header(Name, Req, Default) when Name =:= <<"accept-language">> ->
cowboy_http:nonempty_list(Value, fun cowboy_http:language_range/2)
end);
parse_header(Name, Req, Default) when Name =:= <<"content-length">> ->
- parse_header(Name, Req, Default,
- fun (Value) ->
- cowboy_http:digits(Value)
- end);
+ parse_header(Name, Req, Default, fun cowboy_http:digits/1);
parse_header(Name, Req, Default) when Name =:= <<"content-type">> ->
- parse_header(Name, Req, Default,
- fun (Value) ->
- cowboy_http:content_type(Value)
- end);
+ parse_header(Name, Req, Default, fun cowboy_http:content_type/1);
parse_header(Name, Req, Default) when Name =:= <<"expect">> ->
parse_header(Name, Req, Default,
fun (Value) ->
@@ -446,17 +439,11 @@ parse_header(Name, Req, Default) when Name =:= <<"expect">> ->
end);
parse_header(Name, Req, Default)
when Name =:= <<"if-match">>; Name =:= <<"if-none-match">> ->
- parse_header(Name, Req, Default,
- fun (Value) ->
- cowboy_http:entity_tag_match(Value)
- end);
+ parse_header(Name, Req, Default, fun cowboy_http:entity_tag_match/1);
parse_header(Name, Req, Default)
when Name =:= <<"if-modified-since">>;
Name =:= <<"if-unmodified-since">> ->
- parse_header(Name, Req, Default,
- fun (Value) ->
- cowboy_http:http_date(Value)
- end);
+ parse_header(Name, Req, Default, fun cowboy_http:http_date/1);
%% @todo Extension parameters.
parse_header(Name, Req, Default) when Name =:= <<"transfer-encoding">> ->
parse_header(Name, Req, Default,