From f80cfab5d7c2641822c45f3ebe04d900c1c3ac5e Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Sun, 14 Nov 2010 16:28:30 +0200 Subject: [PATCH] Cookie expire dates fixed --- Yesod/Content.hs | 7 ++++++- Yesod/Dispatch.hs | 2 +- yesod.cabal | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Yesod/Content.hs b/Yesod/Content.hs index f8af3092..7d4d5683 100644 --- a/Yesod/Content.hs +++ b/Yesod/Content.hs @@ -45,6 +45,7 @@ module Yesod.Content -- * Utilities , formatW3 , formatRFC1123 + , formatCookieExpires #if TEST , testSuite #endif @@ -249,10 +250,14 @@ caseTypeByExt = do Just typeHtml @=? lookup (ext "foo.html") typeByExt #endif --- | Format a 'UTCTime' in W3 format; useful for setting cookies. +-- | Format a 'UTCTime' in W3 format. formatW3 :: UTCTime -> String formatW3 = formatTime defaultTimeLocale "%FT%X-00:00" -- | Format as per RFC 1123. formatRFC1123 :: UTCTime -> String formatRFC1123 = formatTime defaultTimeLocale "%a, %d %b %Y %X %Z" + +-- | Format a 'UTCTime' for a cookie. +formatCookieExpires :: UTCTime -> String +formatCookieExpires = formatTime defaultTimeLocale "%a, %d-%b-%Y %X GMT" diff --git a/Yesod/Dispatch.hs b/Yesod/Dispatch.hs index ff79c15b..a3021503 100644 --- a/Yesod/Dispatch.hs +++ b/Yesod/Dispatch.hs @@ -385,7 +385,7 @@ headerToPair getExpires (AddCookie minutes key value) = let expires = getExpires minutes in ("Set-Cookie", charsToBs $ key ++ "=" ++ value ++"; path=/; expires=" - ++ formatW3 expires) + ++ formatCookieExpires expires) headerToPair _ (DeleteCookie key) = ("Set-Cookie", charsToBs $ key ++ "=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT") diff --git a/yesod.cabal b/yesod.cabal index 3fd7ef4d..33bf98e9 100644 --- a/yesod.cabal +++ b/yesod.cabal @@ -1,5 +1,5 @@ name: yesod -version: 0.6.1.2 +version: 0.6.1.3 license: BSD3 license-file: LICENSE author: Michael Snoyman