aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_http_req.erl
diff options
context:
space:
mode:
authorTom Burdick <[email protected]>2011-07-18 15:50:29 -0500
committerLoïc Hoguin <[email protected]>2011-07-26 13:53:52 +0200
commitb75859e07511fc07954542872dd18548f3f7d4fc (patch)
treeb92fab7616a28eeb3aa98b34665f0ec4467cb879 /src/cowboy_http_req.erl
parent5bd936db6606a27dfd91a0e2675889b58c212376 (diff)
downloadcowboy-b75859e07511fc07954542872dd18548f3f7d4fc.tar.gz
cowboy-b75859e07511fc07954542872dd18548f3f7d4fc.tar.bz2
cowboy-b75859e07511fc07954542872dd18548f3f7d4fc.zip
Fail early in cookie-related API functions
Diffstat (limited to 'src/cowboy_http_req.erl')
-rw-r--r--src/cowboy_http_req.erl4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/cowboy_http_req.erl b/src/cowboy_http_req.erl
index 323f750..69d47b0 100644
--- a/src/cowboy_http_req.erl
+++ b/src/cowboy_http_req.erl
@@ -181,14 +181,14 @@ headers(Req) ->
%% @equiv cookie(Name, Req, undefined)
-spec cookie(binary(), #http_req{})
-> {binary() | true | undefined, #http_req{}}.
-cookie(Name, Req) ->
+cookie(Name, Req) when is_binary(Name) ->
cookie(Name, Req, undefined).
%% @doc Return the cookie value for the given key, or a default if
%% missing.
-spec cookie(binary(), #http_req{}, Default)
-> {binary() | true | Default, #http_req{}} when Default::any().
-cookie(Name, Req=#http_req{cookies=undefined}, Default) ->
+cookie(Name, Req=#http_req{cookies=undefined}, Default) when is_binary(Name) ->
case header('Cookie', Req) of
{undefined, Req2} ->
{Default, Req2#http_req{cookies=[]}};