http-client-conduit 0.2.0.1 → 0.3.0
raw patch · 2 files changed
+3/−99 lines, 2 filesdep −bytestringdep −conduitdep −resourcetdep ~http-client
Dependencies removed: bytestring, conduit, resourcet, transformers
Dependency ranges changed: http-client
Files
− Network/HTTP/Client/Conduit.hs
@@ -1,91 +0,0 @@-{-# LANGUAGE RankNTypes #-}--- | Frontend support for using http-client with conduit. Intended for use with--- higher-level libraries like http-conduit.-module Network.HTTP.Client.Conduit- ( requestBodySource- , requestBodySourceChunked- , requestBodySourceIO- , requestBodySourceChunkedIO- , bodyReaderSource- , http- ) where--import Data.Conduit-import qualified Data.Conduit.Internal as CI-import Control.Monad.Trans.Resource-import Network.HTTP.Client-import Network.HTTP.Client.Internal-import Data.Int (Int64)-import qualified Data.ByteString as S-import Data.ByteString (ByteString)-import Data.IORef-import Control.Monad.IO.Class (MonadIO, liftIO)-import Control.Monad (unless)--bodyReaderSource :: MonadIO m- => BodyReader- -> Producer m ByteString-bodyReaderSource br =- loop- where- loop = do- bs <- liftIO $ brRead br- unless (S.null bs) $ do- yield bs- loop--http :: MonadResource m- => Request- -> Manager- -> m (Response (ResumableSource m ByteString))-http req man = do- (key, res) <- allocate (responseOpen req man) responseClose- let rsrc = CI.ResumableSource- (bodyReaderSource $ responseBody res)- (release key)- return res { responseBody = rsrc }--requestBodySource :: Int64 -> Source (ResourceT IO) ByteString -> RequestBody-requestBodySource size = RequestBodyStream size . srcToPopper--requestBodySourceChunked :: Source (ResourceT IO) ByteString -> RequestBody-requestBodySourceChunked = RequestBodyStreamChunked . srcToPopper--srcToPopper :: Source (ResourceT IO) ByteString -> GivesPopper ()-srcToPopper src f = runResourceT $ do- (rsrc0, ()) <- src $$+ return ()- irsrc <- liftIO $ newIORef rsrc0- is <- getInternalState- let popper :: IO ByteString- popper = do- rsrc <- readIORef irsrc- (rsrc', mres) <- runInternalState (rsrc $$++ await) is- writeIORef irsrc rsrc'- case mres of- Nothing -> return S.empty- Just bs- | S.null bs -> popper- | otherwise -> return bs- liftIO $ f popper--requestBodySourceIO :: Int64 -> Source IO ByteString -> RequestBody-requestBodySourceIO size = RequestBodyStream size . srcToPopperIO--requestBodySourceChunkedIO :: Source IO ByteString -> RequestBody-requestBodySourceChunkedIO = RequestBodyStreamChunked . srcToPopperIO--srcToPopperIO :: Source IO ByteString -> GivesPopper ()-srcToPopperIO src f = do- (rsrc0, ()) <- src $$+ return ()- irsrc <- newIORef rsrc0- let popper :: IO ByteString- popper = do- rsrc <- readIORef irsrc- (rsrc', mres) <- rsrc $$++ await- writeIORef irsrc rsrc'- case mres of- Nothing -> return S.empty- Just bs- | S.null bs -> popper- | otherwise -> return bs- f popper
http-client-conduit.cabal view
@@ -1,6 +1,6 @@ name: http-client-conduit-version: 0.2.0.1-synopsis: Frontend support for using http-client with conduit+version: 0.3.0+synopsis: Frontend support for using http-client with conduit (deprecated) description: Intended for use by higher-level libraries, such as http-conduit. homepage: https://github.com/snoyberg/http-client license: MIT@@ -12,11 +12,6 @@ cabal-version: >=1.10 library- exposed-modules: Network.HTTP.Client.Conduit build-depends: base >= 4 && < 5- , http-client >= 0.2- , conduit- , resourcet >= 0.4.6- , bytestring- , transformers+ , http-client >= 0.3 default-language: Haskell2010