summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichaelSnoyman <>2017-12-05 05:12:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2017-12-05 05:12:00 (GMT)
commit23f62319d6d33fa5b7ab5609eb53d4163b57c040 (patch)
tree7029a5c0d5a6c01490337461106d41a68cc00ef3
parent6616ee83ecce49b28e876124fe1d6ae72d72e63d (diff)
version 2.2.42.2.4
-rw-r--r--ChangeLog.md4
-rw-r--r--Network/HTTP/Simple.hs25
-rw-r--r--http-conduit.cabal2
3 files changed, 23 insertions, 8 deletions
diff --git a/ChangeLog.md b/ChangeLog.md
index 556fa0c..dfc8eba 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -1,3 +1,7 @@
+## 2.2.4
+
+* Add `httpBS` to `Network.HTTP.Simple`
+
## 2.2.3.2
* Add proper headers for `httpJSON` and `httpJSONEither` [#284](https://github.com/snoyberg/http-client/issues/284)
diff --git a/Network/HTTP/Simple.hs b/Network/HTTP/Simple.hs
index 0f39212..22a0927 100644
--- a/Network/HTTP/Simple.hs
+++ b/Network/HTTP/Simple.hs
@@ -11,15 +11,16 @@
--
-- > {-# LANGUAGE OverloadedStrings #-}
-- > import Network.HTTP.Simple
--- > import qualified Data.ByteString.Lazy.Char8 as L8
+-- > import qualified Data.ByteString.Char8 as B8
-- >
-- > main :: IO ()
--- > main = httpLBS "http://example.com" >>= L8.putStrLn
+-- > main = httpBS "http://example.com" >>= B8.putStrLn . getResponseBody
--
-- The `Data.String.IsString` instance uses `H.parseRequest` behind the scenes and inherits its behavior.
module Network.HTTP.Simple
( -- * Perform requests
- httpLBS
+ httpBS
+ , httpLBS
, httpNoBody
, httpJSON
, httpJSONEither
@@ -93,9 +94,19 @@ import qualified Network.HTTP.Types as H
import Data.Int (Int64)
import Control.Monad.Trans.Resource (MonadResource)
--- | Perform an HTTP request and return the body as a lazy @ByteString@. Note
--- that the entire value will be read into memory at once (no lazy I\/O will be
--- performed).
+-- | Perform an HTTP request and return the body as a @ByteString@.
+--
+-- @since 2.2.4
+httpBS :: MonadIO m => H.Request -> m (H.Response S.ByteString)
+httpBS req = liftIO $ do
+ man <- H.getGlobalManager
+ fmap L.toStrict `fmap` H.httpLbs req man
+
+-- | Perform an HTTP request and return the body as a lazy
+-- @ByteString@. Note that the entire value will be read into memory
+-- at once (no lazy I\/O will be performed). The advantage of a lazy
+-- @ByteString@ here (versus using 'httpBS') is--if needed--a better
+-- in-memory representation.
--
-- @since 2.1.10
httpLBS :: MonadIO m => H.Request -> m (H.Response L.ByteString)
@@ -317,7 +328,7 @@ setRequestBody x req = req { H.requestBody = x }
-- /Note/: This will not modify the request method. For that, please use
-- 'requestMethod'. You likely don't want the default of @GET@.
--
--- This also sets the @content-type@ to @application/json; chatset=utf8@
+-- This also sets the @Content-Type@ to @application/json; charset=utf-8@
--
-- @since 2.1.10
setRequestBodyJSON :: A.ToJSON a => a -> H.Request -> H.Request
diff --git a/http-conduit.cabal b/http-conduit.cabal
index f04989d..e753c4a 100644
--- a/http-conduit.cabal
+++ b/http-conduit.cabal
@@ -1,5 +1,5 @@
name: http-conduit
-version: 2.2.3.2
+version: 2.2.4
license: BSD3
license-file: LICENSE
author: Michael Snoyman <michael@snoyman.com>