packages feed

cookie 0.2.0 → 0.2.1

raw patch · 2 files changed

+25/−6 lines, 2 filesdep +textPVP ok

version bump matches the API change (PVP)

Dependencies added: text

API changes (from Hackage documentation)

+ Web.Cookie: parseCookiesText :: ByteString -> CookiesText
+ Web.Cookie: renderCookiesText :: CookiesText -> Builder
+ Web.Cookie: type CookiesText = [(Text, Text)]

Files

Web/Cookie.hs view
@@ -8,6 +8,10 @@     , Cookies     , parseCookies     , renderCookies+      -- ** UTF8 Version+    , CookiesText+    , parseCookiesText+    , renderCookiesText       -- * Expires field     , expiresFormat     , formatCookieExpires@@ -24,19 +28,33 @@ import Data.Time (UTCTime, formatTime, parseTime) import System.Locale (defaultTimeLocale) import Control.Arrow (first)+import Data.Text (Text)+import Data.Text.Encoding (encodeUtf8, decodeUtf8With)+import Data.Text.Encoding.Error (lenientDecode)+import Control.Arrow ((***)) +-- | Textual cookies. Functions assume UTF8 encoding.+type CookiesText = [(Text, Text)]++parseCookiesText :: S.ByteString -> CookiesText+parseCookiesText =+    map (go *** go) . parseCookies+  where+    go = decodeUtf8With lenientDecode++-- FIXME to speed things up, skip encodeUtf8 and use fromText instead+renderCookiesText :: CookiesText -> Builder+renderCookiesText = renderCookies . map (encodeUtf8 *** encodeUtf8)+ type Cookies = [(S.ByteString, S.ByteString)]  -- | Decode the value of a \"Cookie\" request header into key/value pairs. parseCookies :: S.ByteString -> Cookies-parseCookies = parseCookiesBS--parseCookiesBS :: S.ByteString -> Cookies-parseCookiesBS s+parseCookies s   | S.null s = []   | otherwise =     let (x, y) = breakDiscard 59 s -- semicolon-     in parseCookie x : parseCookiesBS y+     in parseCookie x : parseCookies y  parseCookie :: S.ByteString -> (S.ByteString, S.ByteString) parseCookie s =
cookie.cabal view
@@ -1,5 +1,5 @@ name:            cookie-version:         0.2.0+version:         0.2.1 license:         BSD3 license-file:    LICENSE author:          Michael Snoyman <michael@snoyman.com>@@ -17,6 +17,7 @@                    , blaze-builder             >= 0.2.1    && < 0.4                    , old-locale                >= 1        && < 1.1                    , time                      >= 1.1.4    && < 1.3+                   , text                      >= 0.7      && < 1.0     exposed-modules: Web.Cookie     ghc-options:     -Wall