packages feed

wai-extra 1.3.2.1 → 1.3.2.2

raw patch · 3 files changed

+67/−7 lines, 3 filesdep ~basedep ~blaze-builder-conduitdep ~conduit

Dependency ranges changed: base, blaze-builder-conduit, conduit, zlib-conduit

Files

Network/Wai/Handler/CGI.hs view
@@ -141,7 +141,7 @@         , fromByteString sf         , fromByteString " not supported"         ]-    bsSink = awaitE >>= either return push+    bsSink = await >>= maybe (return ()) push     push (Chunk bs) = do         liftIO $ outputH bs         bsSink
Network/Wai/Parse.hs view
@@ -2,6 +2,7 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ExistentialQuantification #-} {-# LANGUAGE PatternGuards #-}+{-# LANGUAGE TypeFamilies #-} -- | Some helpers for parsing data out of a raw WAI 'Request'.  module Network.Wai.Parse@@ -50,6 +51,10 @@ import Control.Monad (when, unless) import Control.Monad.Trans.Class (lift) import Control.Monad.Trans.Resource (allocate, release, register)+#if MIN_VERSION_conduit(1, 0, 0)+import Data.Conduit.Internal (Pipe (NeedInput, HaveOutput), (>+>), withUpstream, Sink (..), injectLeftovers, ConduitM (..))+import Data.Void (Void)+#endif  breakDiscard :: Word8 -> S.ByteString -> (S.ByteString, S.ByteString) breakDiscard w s =@@ -184,7 +189,11 @@ conduitRequestBody backend (Multipart bound) =     parsePieces backend $ S8.pack "--" `S.append` bound +#if MIN_VERSION_conduit(1, 0, 0)+takeLine :: Monad m => Consumer S.ByteString m (Maybe S.ByteString)+#else takeLine :: Monad m => Pipe S.ByteString S.ByteString o u m (Maybe S.ByteString)+#endif takeLine =     go id   where@@ -199,7 +208,11 @@                     when (S.length y > 1) $ leftover $ S.drop 1 y                     return $ Just $ killCR x +#if MIN_VERSION_conduit(1, 0, 0)+takeLines :: Consumer S.ByteString (ResourceT IO) [S.ByteString]+#else takeLines :: Pipe S.ByteString S.ByteString o u (ResourceT IO) [S.ByteString]+#endif takeLines = do     res <- takeLine     case res of@@ -212,7 +225,11 @@  parsePieces :: BackEnd y             -> S.ByteString+#if MIN_VERSION_conduit(1, 0, 0)+            -> ConduitM S.ByteString (Either Param (File y)) (ResourceT IO) ()+#else             -> Pipe S.ByteString S.ByteString (Either Param (File y)) u (ResourceT IO) ()+#endif parsePieces sink bound =     loop   where@@ -287,13 +304,41 @@                -> S.ByteString                -> FileInfo ()                -> BackEnd y+#if MIN_VERSION_conduit(1, 0, 0)+               -> ConduitM S.ByteString o (ResourceT IO) (Bool, y)+#else                -> Pipe S.ByteString S.ByteString o u (ResourceT IO) (Bool, y)-sinkTillBound' bound name fi sink = conduitTillBound bound >+> withUpstream (sinkToPipe $ sink name fi)+#endif+sinkTillBound' bound name fi sink =+#if MIN_VERSION_conduit(1, 0, 0)+    ConduitM $ anyOutput $+#endif+    conduitTillBound bound >+> withUpstream (fix $ sink name fi)+  where+#if MIN_VERSION_conduit(1, 0, 0)+    fix :: Sink S8.ByteString (ResourceT IO) y -> Pipe Void S8.ByteString Void Bool (ResourceT IO) y+    fix (ConduitM p) = ignoreTerm >+> injectLeftovers p+    ignoreTerm = await' >>= maybe (return ()) (\x -> yield' x >> ignoreTerm)+    await' = NeedInput (return . Just) (const $ return Nothing)+    yield' = HaveOutput (return ()) (return ()) +    anyOutput p = p >+> dropInput+    dropInput = NeedInput (const dropInput) return+#else+    fix = sinkToPipe+#endif+ conduitTillBound :: Monad m                  => S.ByteString -- bound+#if MIN_VERSION_conduit(1, 0, 0)+                 -> Pipe S.ByteString S.ByteString S.ByteString () m Bool+#else                  -> Pipe S.ByteString S.ByteString S.ByteString u m Bool+#endif conduitTillBound bound =+#if MIN_VERSION_conduit(1, 0, 0)+    unConduitM $+#endif     go id   where     go front = await >>= maybe (close front) (push front)@@ -323,11 +368,26 @@ sinkTillBound :: S.ByteString               -> (x -> S.ByteString -> IO x)               -> x+#if MIN_VERSION_conduit(1, 0, 0)+              -> Consumer S.ByteString (ResourceT IO) (Bool, x)+#else               -> Pipe S.ByteString S.ByteString o u (ResourceT IO) (Bool, x)+#endif sinkTillBound bound iter seed0 =-    conduitTillBound bound >+> withUpstream (CL.foldM iter' seed0)+#if MIN_VERSION_conduit(1, 0, 0)+    ConduitM $+#endif+    (conduitTillBound bound >+> (withUpstream $ ij $ CL.foldM iter' seed0))   where     iter' a b = liftIO $ iter a b+#if MIN_VERSION_conduit(1, 0, 0)+    ij (ConduitM p) = ignoreTerm >+> injectLeftovers p+    ignoreTerm = await' >>= maybe (return ()) (\x -> yield' x >> ignoreTerm)+    await' = NeedInput (return . Just) (const $ return Nothing)+    yield' = HaveOutput (return ()) (return ())+#else+    ij = id+#endif  parseAttrs :: S.ByteString -> [(S.ByteString, S.ByteString)] parseAttrs = map go . S.split 59 -- semicolon
wai-extra.cabal view
@@ -1,5 +1,5 @@ Name:                wai-extra-Version:             1.3.2.1+Version:             1.3.2.2 Synopsis:            Provides some basic WAI handlers and middleware. Description:         The goal here is to provide common features without many dependencies. License:             MIT@@ -36,9 +36,9 @@                    , date-cache                >= 0.3      && < 0.4                    , fast-logger               >= 0.2      && < 0.4                    , wai-logger                >= 0.2      && < 0.4-                   , conduit                   >= 0.5      && < 0.6-                   , zlib-conduit              >= 0.5      && < 0.6-                   , blaze-builder-conduit     >= 0.5      && < 0.6+                   , conduit                   >= 0.5      && < 1.1+                   , zlib-conduit              >= 0.5      && < 1.1+                   , blaze-builder-conduit     >= 0.5      && < 1.1                    , ansi-terminal                    , resourcet                 >= 0.3      && < 0.5                    , void                      >= 0.5      && < 0.6