HTTP module:Network -package:amazonka-s3 package:http-conduit

An exception which may be generated by this library
Most exceptions are specific to a Request. Inspect the HttpExceptionContent value for details on what occurred.
An exception was thrown when inflating a response body.
Same as httpLbs, except it uses the Manager in the reader environment. Since 2.1.1
Same as httpNoBody, except it uses the Manager in the reader environment. This can be more convenient that using withManager as it avoids the need to specify the base monad for the response body. Since 2.1.2
Same as httpSource, but uses Manager from Reader environment instead of the global one. Since 2.3.6
Download the specified Request, returning the results as a Response. This is a simplified version of http for the common case where you simply want the response data as a simple datatype. If you want more power, such as interleaved actions on the response body during download, you'll need to use http directly. This function is defined as:
httpLbs = lbsResponse <=< http
Even though the Response contains a lazy bytestring, this function does not utilize lazy I/O, and therefore the entire response body will live in memory. If you want constant memory usage, you'll need to use conduit packages's Source returned by http. This function will throwIO an HttpException for any response with a non-2xx status code (besides 3xx redirects up to a limit of 10 redirects). This behavior can be modified by changing the checkStatus field of your request. Note: Unlike previous versions, this function will perform redirects, as specified by the redirectCount setting.
Perform an HTTP request and return the body as a ByteString.
Perform an HTTP request and parse the body as JSON. In the event of an JSON parse errors, a JSONException runtime exception will be thrown. NOTE: Depends on the aeson cabal flag being enabled
Perform an HTTP request and parse the body as JSON. In the event of an JSON parse errors, a Left value will be returned. NOTE: Depends on the aeson cabal flag being enabled
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.
Alternate spelling of httpLBS
Perform an HTTP request and ignore the response body.
Perform an HTTP request and consume the body with the given Sink
Perform an HTTP request, and get the response body as a Source. The second argument to this function tells us how to make the Source from the Response itself. This allows you to perform actions with the status or headers, for example, in addition to the raw bytes themselves. If you just care about the response body, you can use getResponseBody as the second argument here.
{-# LANGUAGE OverloadedStrings #-}
import           Control.Monad.IO.Class       (liftIO)
import           Control.Monad.Trans.Resource (runResourceT)
import           Data.Conduit                 (($$))
import qualified Data.Conduit.Binary          as CB
import qualified Data.Conduit.List            as CL
import           Network.HTTP.Simple
import           System.IO                    (stdout)

main :: IO ()
main =
runResourceT
$ httpSource "http://httpbin.org/robots.txt" getSrc
$$ CB.sinkHandle stdout
where
getSrc res = do
liftIO $ print (getResponseStatus res, getResponseHeaders res)
getResponseBody res
Download the specified URL, following any redirects, and return the response body. This function will throwIO an HttpException for any response with a non-2xx status code (besides 3xx redirects up to a limit of 10 redirects). It uses parseUrlThrow to parse the input. This function essentially wraps httpLbs. Note: Even though this function returns a lazy bytestring, it does not utilize lazy I/O, and therefore the entire response body will live in memory. If you want constant memory usage, you'll need to use the conduit package and http directly. Note: This function creates a new Manager. It should be avoided in production code.