Support clj-time Intervals/DateTime for :max-age and :expires #62
+72
−7
Thanks for the work you've put into this so far! There are a few issues though...
The :expires attribute should not be a Unix timestamp, but in a format like "Wdy, DD Mon YYYY HH:MM:SS GMT". I believe the cookie spec gives some leeway, and as far as I can tell, the :rfc822 format type that clj-time has built in should create a cookie-compatible date string.
I think it would be something like:
(unparse (formatters :rfc822) value)The valid-attr? function could be refactored a little by writing the cond as part of the and, e.g.
(and (contains? set-cookie-attrs key)
(not (.contains (str value) ";")
(case key
:max-age (or (instance? Interval value) (integer? value))
:expires (or (instance? DateTime value) (string? value))
true))Finally, I think your branch is a little out of date, as GitHub is telling me no automatic merging. You might want to rebase it off master.
KushalP
commented
Mar 19, 2012
The commits have now been squashed into a single commit, rather than the intermediate steps.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This fixes #55.
Each commit appears with a header and body description for what I've done.
Here's a quick summary:
:max-ageand:expiresaccept an integer (as originally outlined):max-agenow accepts anInterval— this is exercised through tests:expiresnow accepts aDateTime— exercised through testsLet me know if any further work needs to be done.