diff options
author | Krzysztof Jurewicz <[email protected]> | 2015-07-21 11:10:47 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2015-11-16 17:09:42 +0100 |
commit | e6a1f1a4f30bad94baad718c0d4b9945b5c2c903 (patch) | |
tree | 349d85d4aea8ad43e19c1443260b6abff1e8b582 | |
parent | 5e69b111789f2e6cdc58cff3b1e631505b26fd4e (diff) | |
download | cowlib-e6a1f1a4f30bad94baad718c0d4b9945b5c2c903.tar.gz cowlib-e6a1f1a4f30bad94baad718c0d4b9945b5c2c903.tar.bz2 cowlib-e6a1f1a4f30bad94baad718c0d4b9945b5c2c903.zip |
Fix handling of default values in cookie options
Previously, an error would be raised when explicitly passing a default
value for either “http_only” or “secure” option.
-rw-r--r-- | src/cow_cookie.erl | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/cow_cookie.erl b/src/cow_cookie.erl index 6db89be..4e36ec4 100644 --- a/src/cow_cookie.erl +++ b/src/cow_cookie.erl @@ -197,10 +197,12 @@ setcookie(Name, Value, Opts) -> end, SecureBin = case lists:keyfind(secure, 1, Opts) of false -> <<>>; + {_, false} -> <<>>; {_, true} -> <<"; Secure">> end, HttpOnlyBin = case lists:keyfind(http_only, 1, Opts) of false -> <<>>; + {_, false} -> <<>>; {_, true} -> <<"; HttpOnly">> end, [Name, <<"=">>, Value, <<"; Version=1">>, @@ -218,6 +220,12 @@ setcookie_test_() -> [{path, <<"/acme">>}], <<"Customer=WILE_E_COYOTE; Version=1; Path=/acme">>}, {<<"Customer">>, <<"WILE_E_COYOTE">>, + [{secure, true}], + <<"Customer=WILE_E_COYOTE; Version=1; Secure">>}, + {<<"Customer">>, <<"WILE_E_COYOTE">>, + [{secure, false}, {http_only, false}], + <<"Customer=WILE_E_COYOTE; Version=1">>}, + {<<"Customer">>, <<"WILE_E_COYOTE">>, [{path, <<"/acme">>}, {badoption, <<"negatory">>}], <<"Customer=WILE_E_COYOTE; Version=1; Path=/acme">>} ], |