From b75859e07511fc07954542872dd18548f3f7d4fc Mon Sep 17 00:00:00 2001 From: Tom Burdick Date: Mon, 18 Jul 2011 15:50:29 -0500 Subject: Fail early in cookie-related API functions --- src/cowboy_cookies.erl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/cowboy_cookies.erl') diff --git a/src/cowboy_cookies.erl b/src/cowboy_cookies.erl index acaefee..8a11b19 100644 --- a/src/cowboy_cookies.erl +++ b/src/cowboy_cookies.erl @@ -43,17 +43,17 @@ -spec parse_cookie(binary()) -> kvlist(). parse_cookie(<<>>) -> []; -parse_cookie(Cookie) -> +parse_cookie(Cookie) when is_binary(Cookie) -> parse_cookie(Cookie, []). %% @doc Short-hand for cookie(Key, Value, []). -spec cookie(binary(), binary()) -> kvlist(). -cookie(Key, Value) -> +cookie(Key, Value) when is_binary(Key) andalso is_binary(Value) -> cookie(Key, Value, []). %% @doc Generate a Set-Cookie header field tuple. -spec cookie(binary(), binary(), [cookie_option()]) -> kvlist(). -cookie(Key, Value, Options) -> +cookie(Key, Value, Options) when is_binary(Key) andalso is_binary(Value) andalso is_list(Options) -> Cookie = <<(any_to_binary(Key))/binary, "=", (quote(Value))/binary, "; Version=1">>, %% Set-Cookie: %% Comment, Domain, Max-Age, Path, Secure, Version -- cgit v1.2.3