packages feed

req-conduit 0.1.0 → 0.2.0

raw patch · 7 files changed

+40/−157 lines, 7 filesdep ~reqdep ~req-conduitdep ~weighPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: req, req-conduit, weigh

API changes (from Hackage documentation)

- Network.HTTP.Req.Conduit: req' :: (MonadHttp m, HttpMethod method, HttpBody body, HttpBodyAllowed (AllowsBody method) (ProvidesBody body)) => method -> Url scheme -> body -> (Request -> Manager -> m a) -> Option scheme -> m a

Files

CHANGELOG.md view
@@ -1,3 +1,9 @@+## Req Conduit 0.2.0++* This version is to be used with Req 0.3.0.++* Removed `req'` as it's now in Req itself.+ ## Req Conduit 0.1.0  * Initial release.
LICENSE.md view
@@ -1,4 +1,4 @@-Copyright © 2016 Mark Karpov+Copyright © 2016–2017 Mark Karpov  All rights reserved. 
Network/HTTP/Req/Conduit.hs view
@@ -1,9 +1,9 @@ -- | -- Module      :  Network.HTTP.Req.Conduit--- Copyright   :  © 2016 Mark Karpov, Michael Snoyman+-- Copyright   :  © 2016–2017 Mark Karpov, Michael Snoyman -- License     :  BSD 3 clause ----- Maintainer  :  Mark Karpov <markkarpov@openmailbox.org>+-- Maintainer  :  Mark Karpov <markkarpov92@gmail.com> -- Stability   :  experimental -- Portability :  portable --@@ -26,7 +26,6 @@     ReqBodySource (..)     -- * Streaming response bodies     -- $streaming-response-  , req'   , httpSource ) where @@ -45,7 +44,7 @@ ---------------------------------------------------------------------------- -- Request bodies --- | This body option streams contents of request body from given+-- | This body option streams contents of request body from the given -- 'C.Source'. The 'Int64' value is size of the data in bytes. -- -- Using of this body option does not set the @Content-Type@ header.@@ -62,8 +61,8 @@ -- $streaming-response -- -- Streaming response is a bit tricky as acquiring and releasing a resource--- (initiating a connection and then closing it in our case) in context of--- @conduit@ streaming requires working with+-- (initiating a connection and then closing it in our case) in the context+-- of @conduit@ streaming requires working with the -- 'Control.Monad.Trans.Resource.ResourceT' monad transformer. This does not -- play well with the framework @req@ builds. --@@ -75,7 +74,7 @@ --       time the instance won't be necessary. --     * Use the 'withReqManager' in combination with 'ReturnRequest' --       response interpretation to get both 'L.Manager' and 'L.Request' and---       then delegate the work to to a custom callback.+--       then delegate the work to a custom callback. -- -- We go with the second option. Here is an example of how to stream 100000 -- bytes and save them to a file:@@ -99,27 +98,8 @@ -- > main :: IO () -- > main = runConduitRes $ do -- >   let size = 100000 :: Int--- >   req' GET (https "httpbin.org" /: "bytes" /~ size) NoReqBody httpSource mempty+-- >   req' GET (https "httpbin.org" /: "bytes" /~ size) NoReqBody mempty httpSource -- >     =$= CB.sinkFile "my-favorite-file.bin"---- | Mostly like 'req' with respect to its arguments, but instead of a hint--- how to interpret response it takes a callback that allows to perform a--- request using arbitrary code.--req'-  :: ( MonadHttp  m-     , HttpMethod method-     , HttpBody   body-     , HttpBodyAllowed (AllowsBody method) (ProvidesBody body) )-  => method            -- ^ HTTP method-  -> Url scheme        -- ^ 'Url' — location of resource-  -> body              -- ^ Body of the request-  -> (L.Request -> L.Manager -> m a) -- ^ How to perform actual request-  -> Option scheme     -- ^ Collection of optional parameters-  -> m a               -- ^ Result-req' method url body m options = do-  request <- responseRequest `liftM` req method url body returnRequest options-  withReqManager (m request)  -- | Perform an HTTP request and get the response as a 'C.Producer'. 
README.md view
@@ -12,14 +12,6 @@ with [`conduit`](https://hackage.haskell.org/package/conduit) helpers for streaming big request bodies in constant space. -## Potential issues--Streaming of request body does not happen in constant memory. But it does-not work with `http-conduit` either, see:-https://github.com/snoyberg/http-client/issues/240. Streaming of response-body does happen in constant memory as expected. See the benchmarks coming-with the library for hands-on experiences.- ## Contribution  Issues, bugs, and questions may be reported in [the GitHub issue tracker for@@ -29,6 +21,6 @@  ## License -Copyright © 2016 Mark Karpov, Micheal Snoyman+Copyright © 2016–2017 Mark Karpov, Michael Snoyman  Distributed under BSD 3 clause license.
httpbin-tests/Network/HTTP/Req/ConduitSpec.hs view
@@ -1,36 +1,3 @@------ Tests for ‘req-conduit’ package. This test suite tests streaming large--- request and response bodies.------ Copyright © 2016 Mark Karpov <markkarpov@openmailbox.org>------ Redistribution and use in source and binary forms, with or without--- modification, are permitted provided that the following conditions are--- met:------ * Redistributions of source code must retain the above copyright notice,---   this list of conditions and the following disclaimer.------ * Redistributions in binary form must reproduce the above copyright---   notice, this list of conditions and the following disclaimer in the---   documentation and/or other materials provided with the distribution.------ * Neither the name Mark Karpov nor the names of contributors may be used---   to endorse or promote products derived from this software without---   specific prior written permission.------ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS “AS IS” AND ANY--- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED--- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE--- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY--- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL--- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS--- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)--- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,--- STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN--- ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE--- POSSIBILITY OF SUCH DAMAGE.- {-# LANGUAGE CPP                  #-} {-# LANGUAGE DataKinds            #-} {-# LANGUAGE FlexibleInstances    #-}@@ -63,24 +30,24 @@ spec :: Spec spec = do -  describe "streaming 100 M request" $+  describe "streaming 10 M request" $     it "works" $ do       let size :: Int64-          size = 100 * 1024 * 1024-          src = CL.replicate (100 * 1024) (B.replicate 1024 0)+          size = 10 * 1024 * 1024+          src = CL.replicate (10 * 1024) (B.replicate 1024 0)       void (req POST (httpbin /: "post")         (ReqBodySource size src) ignoreResponse mempty) :: IO () -  describe "streaming 100 M response" $+  describe "streaming 10 M response" $     it "works" $ do       let tempi :: (Handle -> IO ()) -> IO ()           tempi f = withSystemTempFile "req-conduit" (const f)       tempi $ \h ->         runConduitRes $ do           let size :: Int-              size = 100 * 1024 * 1024+              size = 10 * 1024 * 1024           req' GET (httpbin /: "stream-bytes" /~ size) NoReqBody-            httpSource mempty =$= CB.sinkHandle h+            mempty httpSource =$= CB.sinkHandle h  ---------------------------------------------------------------------------- -- Instances
req-conduit.cabal view
@@ -1,42 +1,11 @@------ Cabal configuration for ‘req-conduit’ package.------ Copyright © 2016 Mark Karpov <markkarpov@openmailbox.org>------ Redistribution and use in source and binary forms, with or without--- modification, are permitted provided that the following conditions are--- met:------ * Redistributions of source code must retain the above copyright notice,---   this list of conditions and the following disclaimer.------ * Redistributions in binary form must reproduce the above copyright---   notice, this list of conditions and the following disclaimer in the---   documentation and/or other materials provided with the distribution.------ * Neither the name Mark Karpov nor the names of contributors may be used---   to endorse or promote products derived from this software without---   specific prior written permission.------ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS “AS IS” AND ANY--- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED--- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE--- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY--- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL--- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS--- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)--- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,--- STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN--- ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE--- POSSIBILITY OF SUCH DAMAGE.- name:                 req-conduit-version:              0.1.0+version:              0.2.0 cabal-version:        >= 1.10+tested-with:          GHC==7.8.4, GHC==7.10.3, GHC==8.0.2 license:              BSD3 license-file:         LICENSE.md-author:               Mark Karpov <markkarpov@openmailbox.org>, Michael Snoyman <michael@snoyman.com>-maintainer:           Mark Karpov <markkarpov@openmailbox.org>+author:               Mark Karpov <markkarpov92@gmail.com>, Michael Snoyman <michael@snoyman.com>+maintainer:           Mark Karpov <markkarpov92@gmail.com> homepage:             https://github.com/mrkkrp/req-conduit bug-reports:          https://github.com/mrkkrp/req-conduit/issues category:             Network, Web, Conduit@@ -60,7 +29,7 @@                     , bytestring       >= 0.2   && < 0.11                     , conduit          >= 0.5.5 && < 1.3                     , http-client      >= 0.5   && < 0.6-                    , req              >= 0.1   && < 0.2+                    , req              >= 0.3   && < 0.4                     , resourcet        >= 1.1   && < 1.2                     , transformers     >= 0.4   && < 0.6   exposed-modules:    Network.HTTP.Req.Conduit@@ -80,8 +49,8 @@                     , conduit          >= 0.5.5 && < 1.3                     , conduit-extra    >= 1.1.10 && < 1.2                     , hspec            >= 2.0   && < 3.0-                    , req              >= 0.1   && < 0.2-                    , req-conduit      >= 0.1.0+                    , req              >= 0.3   && < 0.4+                    , req-conduit                     , resourcet        >= 1.1   && < 1.2                     , temporary        >= 1.1   && < 1.3                     , transformers     >= 0.4   && < 0.6@@ -99,11 +68,11 @@                     , bytestring       >= 0.2   && < 0.11                     , conduit          >= 0.5.5 && < 1.3                     , conduit-extra    >= 1.1.10 && < 1.2-                    , req              >= 0.1   && < 0.2-                    , req-conduit      >= 0.1.0+                    , req              >= 0.3   && < 0.4+                    , req-conduit                     , resourcet        >= 1.1   && < 1.2                     , temporary        >= 1.1   && < 1.3-                    , weigh            >= 0.0.3+                    , weigh            >= 0.0.4   if flag(dev)     ghc-options:      -O2 -Wall -Werror   else
weigh-bench/Main.hs view
@@ -1,35 +1,3 @@------ Space-consumption benchmark for ‘req-conduit’.------ Copyright © 2016 Mark Karpov <markkarpov@openmailbox.org>------ Redistribution and use in source and binary forms, with or without--- modification, are permitted provided that the following conditions are--- met:------ * Redistributions of source code must retain the above copyright notice,---   this list of conditions and the following disclaimer.------ * Redistributions in binary form must reproduce the above copyright---   notice, this list of conditions and the following disclaimer in the---   documentation and/or other materials provided with the distribution.------ * Neither the name Mark Karpov nor the names of contributors may be used---   to endorse or promote products derived from this software without---   specific prior written permission.------ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS “AS IS” AND ANY--- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED--- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE--- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY--- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL--- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS--- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)--- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,--- STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN--- ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE--- POSSIBILITY OF SUCH DAMAGE.- {-# LANGUAGE DataKinds            #-} {-# LANGUAGE FlexibleInstances    #-} {-# LANGUAGE OverloadedStrings    #-}@@ -53,14 +21,15 @@  main :: IO () main = mainWith $ do-  io "streaming 5   M request  body" bigRequest  (5   * 1024 * 1024)-  io "streaming 25  M request  body" bigRequest  (25  * 1024 * 1024)-  io "streaming 50  M request  body" bigRequest  (50  * 1024 * 1024)-  io "streaming 100 M request  body" bigRequest  (100 * 1024 * 1024)-  io "streaming 5   M response body" bigResponse (5   * 1024 * 1024)-  io "streaming 25  M response body" bigResponse (25  * 1024 * 1024)-  io "streaming 50  M response body" bigResponse (50  * 1024 * 1024)-  io "streaming 100 M response body" bigResponse (100 * 1024 * 1024)+  setColumns [Case, Allocated, GCs, Max]+  io "streaming 1 M request  body" bigRequest  (1 * 1024 * 1024)+  io "streaming 2 M request  body" bigRequest  (2 * 1024 * 1024)+  io "streaming 4 M request  body" bigRequest  (4 * 1024 * 1024)+  io "streaming 8 M request  body" bigRequest  (8 * 1024 * 1024)+  io "streaming 1 M response body" bigResponse (1 * 1024 * 1024)+  io "streaming 2 M response body" bigResponse (2 * 1024 * 1024)+  io "streaming 4 M response body" bigResponse (4 * 1024 * 1024)+  io "streaming 8 M response body" bigResponse (8 * 1024 * 1024)  bigRequest :: Int64 -> IO () bigRequest size' = do