wai-conduit-3.0.0.3/0000755000000000000000000000000012640677145012300 5ustar0000000000000000wai-conduit-3.0.0.3/ChangeLog.md0000644000000000000000000000003612640677145014450 0ustar0000000000000000## 3.0.0.3 * Support wai 3.2 wai-conduit-3.0.0.3/LICENSE0000644000000000000000000000204312640677145013304 0ustar0000000000000000Copyright (c) 2014 Michael Snoyman Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. wai-conduit-3.0.0.3/README.md0000644000000000000000000000023612640677145013560 0ustar0000000000000000## wai-conduit Since version 3.0.0, WAI has no built-in streaming data abstraction. This library provides similar functionality to what existed in WAI 2.x. wai-conduit-3.0.0.3/Setup.hs0000644000000000000000000000005612640677145013735 0ustar0000000000000000import Distribution.Simple main = defaultMain wai-conduit-3.0.0.3/wai-conduit.cabal0000644000000000000000000000161512640677145015512 0ustar0000000000000000name: wai-conduit version: 3.0.0.3 synopsis: conduit wrappers for WAI description: API docs and the README are available at . homepage: https://github.com/yesodweb/wai license: MIT license-file: LICENSE author: Michael Snoyman maintainer: michael@snoyman.com category: Web, Conduit build-type: Simple cabal-version: >=1.10 extra-source-files: README.md ChangeLog.md library exposed-modules: Network.Wai.Conduit build-depends: base >= 4 && < 5 , wai >= 3.0 && < 3.3 , conduit , transformers , bytestring , http-types , blaze-builder default-language: Haskell2010 wai-conduit-3.0.0.3/Network/0000755000000000000000000000000012640677145013731 5ustar0000000000000000wai-conduit-3.0.0.3/Network/Wai/0000755000000000000000000000000012640677145014451 5ustar0000000000000000wai-conduit-3.0.0.3/Network/Wai/Conduit.hs0000644000000000000000000000342012640677145016411 0ustar0000000000000000-- | A light-weight wrapper around @Network.Wai@ to provide easy conduit support. module Network.Wai.Conduit ( -- * Request body sourceRequestBody -- * Response body , responseSource , responseRawSource -- * Re-export , module Network.Wai ) where import Network.Wai import Data.Conduit import Control.Monad.IO.Class (MonadIO, liftIO) import Data.ByteString (ByteString) import qualified Data.ByteString as S import Control.Monad (unless) import Network.HTTP.Types import Blaze.ByteString.Builder (Builder) import Data.IORef import qualified Data.Conduit.List as CL -- | Stream the request body. -- -- Since 3.0.0 sourceRequestBody :: MonadIO m => Request -> Source m ByteString sourceRequestBody req = loop where go = liftIO (requestBody req) loop = do bs <- go unless (S.null bs) $ do yield bs loop -- | Create an HTTP response out of a @Source@. -- -- Since 3.0.0 responseSource :: Status -> ResponseHeaders -> Source IO (Flush Builder) -> Response responseSource s hs src = responseStream s hs $ \send flush -> src $$ CL.mapM_ (\mbuilder -> case mbuilder of Chunk b -> send b Flush -> flush) -- | Create a raw response using a @Source@ and @Sink@ to represent the input -- and output, respectively. -- -- Since 3.0.0 responseRawSource :: (MonadIO m, MonadIO n) => (Source m ByteString -> Sink ByteString n () -> IO ()) -> Response -> Response responseRawSource app = responseRaw app' where app' recv send = app src sink where src = do bs <- liftIO recv unless (S.null bs) $ do yield bs src sink = CL.mapM_ $ liftIO . send