summaryrefslogtreecommitdiff
path: root/Network/HTTP
diff options
context:
space:
mode:
authorMichaelSnoyman <>2019-03-11 11:48:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2019-03-11 11:48:00 (GMT)
commitf7c9af2639e976e2db01590e678e926afee7c108 (patch)
tree477fd3541ffe68de678e9fc39d688c4033c47be6 /Network/HTTP
parent906002fed2d8136718c8dc4c38b2a77b7c104b5e (diff)
version 2.3.62.3.6
Diffstat (limited to 'Network/HTTP')
-rw-r--r--Network/HTTP/Client/Conduit.hs24
-rw-r--r--Network/HTTP/Conduit.hs1
-rw-r--r--Network/HTTP/Simple.hs1
3 files changed, 23 insertions, 3 deletions
diff --git a/Network/HTTP/Client/Conduit.hs b/Network/HTTP/Client/Conduit.hs
index 48e944a..d50e8be 100644
--- a/Network/HTTP/Client/Conduit.hs
+++ b/Network/HTTP/Client/Conduit.hs
@@ -15,6 +15,7 @@ module Network.HTTP.Client.Conduit
, responseOpen
, responseClose
, acquireResponse
+ , httpSource
-- * Manager helpers
, defaultManagerSettings
, newManager
@@ -31,13 +32,14 @@ module Network.HTTP.Client.Conduit
import Control.Monad (unless)
import Control.Monad.IO.Unlift (MonadIO, liftIO, MonadUnliftIO, withRunInIO)
-import Control.Monad.Reader (MonadReader (..))
+import Control.Monad.Reader (MonadReader (..), runReaderT)
+import Control.Monad.Trans.Resource (MonadResource)
import Data.Acquire (Acquire, mkAcquire, with)
import Data.ByteString (ByteString)
import qualified Data.ByteString as S
import qualified Data.ByteString.Lazy as L
-import Data.Conduit (ConduitM, ($$+),
- await, yield, ($$++))
+import Data.Conduit (ConduitM, ($$+), ($$++),
+ await, yield, bracketP)
import Data.Int (Int64)
import Data.IORef (newIORef, readIORef, writeIORef)
import Network.HTTP.Client hiding (closeManager,
@@ -172,3 +174,19 @@ httpNoBody req = do
env <- ask
let man = getHttpManager env
liftIO $ H.httpNoBody req man
+
+-- | Same as 'Network.HTTP.Simple.httpSource', but uses 'Manager'
+-- from Reader environment instead of the global one.
+--
+-- Since 2.3.6
+httpSource
+ :: (MonadResource m, MonadIO n, MonadReader env m, HasHttpManager env)
+ => Request
+ -> (Response (ConduitM () ByteString n ()) -> ConduitM () r m ())
+ -> ConduitM () r m ()
+httpSource request withRes = do
+ env <- ask
+ bracketP
+ (runReaderT (responseOpen request) env)
+ responseClose
+ withRes
diff --git a/Network/HTTP/Conduit.hs b/Network/HTTP/Conduit.hs
index 76c592b..e58b50e 100644
--- a/Network/HTTP/Conduit.hs
+++ b/Network/HTTP/Conduit.hs
@@ -158,6 +158,7 @@ module Network.HTTP.Conduit
, rawBody
, decompress
, redirectCount
+ , shouldStripHeaderOnRedirect
, checkResponse
, responseTimeout
, cookieJar
diff --git a/Network/HTTP/Simple.hs b/Network/HTTP/Simple.hs
index 0690d75..9036f88 100644
--- a/Network/HTTP/Simple.hs
+++ b/Network/HTTP/Simple.hs
@@ -95,6 +95,7 @@ import qualified Data.Aeson.Types as A
import qualified Data.Aeson as A
import qualified Data.Traversable as T
import Control.Exception (throw, throwIO, Exception)
+import Data.Monoid
import Data.Typeable (Typeable)
import qualified Data.Conduit as C
import Data.Conduit (runConduit, (.|), ConduitM)