-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | HTTP client package with conduit interface and HTTPS support.
--   
--   Hackage documentation generation is not reliable. For up to date
--   documentation, please see:
--   http://www.stackage.org/package/http-conduit.
@package http-conduit
@version 2.3.9.1

-- | A new, experimental API to replace Network.HTTP.Conduit.
--   
--   For most users, Network.HTTP.Simple is probably a better
--   choice. For more information, see:
--   
--   https://haskell-lang.org/library/http-client
--   
--   For more information on using this module, please be sure to read the
--   documentation in the Network.HTTP.Client module.
module Network.HTTP.Client.Conduit

-- | Conduit powered version of withResponse. Differences are:
--   
--   
--   
- Response body is represented as a Producer.
--   
- Generalized to any instance of MonadUnliftIO, not just
--   IO.
--   
- The Manager is contained by a MonadReader
--   context.
--   
--   
--   Since 2.1.0
withResponse :: forall m (n :: Type -> Type) env i a. (MonadUnliftIO m, MonadIO n, MonadReader env m, HasHttpManager env) => Request -> (Response (ConduitM i ByteString n ()) -> m a) -> m a

-- | Conduit-powered version of responseOpen.
--   
--   See withResponse for the differences with responseOpen.
--   
--   Since 2.1.0
responseOpen :: forall m (n :: Type -> Type) env i. (MonadIO m, MonadIO n, MonadReader env m, HasHttpManager env) => Request -> m (Response (ConduitM i ByteString n ()))

-- | Generalized version of responseClose.
--   
--   Since 2.1.0
responseClose :: MonadIO m => Response body -> m ()

-- | An Acquire for getting a Response.
--   
--   Since 2.1.0
acquireResponse :: forall (n :: Type -> Type) env m i. (MonadIO n, MonadReader env m, HasHttpManager env) => Request -> m (Acquire (Response (ConduitM i ByteString n ())))

-- | Same as httpSource, but uses Manager from Reader
--   environment instead of the global one.
--   
--   Since 2.3.6
httpSource :: forall (m :: Type -> Type) (n :: Type -> Type) env r. (MonadResource m, MonadIO n, MonadReader env m, HasHttpManager env) => Request -> (Response (ConduitM () ByteString n ()) -> ConduitM () r m ()) -> ConduitM () r m ()

-- | TLS-powered manager settings.
--   
--   Since 2.1.0
defaultManagerSettings :: ManagerSettings

-- | Get a new manager using defaultManagerSettings.
--   
--   Since 2.1.0
newManager :: MonadIO m => m Manager

-- | Get a new manager using the given settings.
--   
--   Since 2.1.0
newManagerSettings :: MonadIO m => ManagerSettings -> m Manager

-- | Define a HTTP proxy, consisting of a hostname and port number.
data Proxy
Proxy :: ByteString -> Int -> Proxy

-- | The host name of the HTTP proxy in URI format. IPv6 addresses in
--   square brackets.
[proxyHost] :: Proxy -> ByteString

-- | The port number of the HTTP proxy.
[proxyPort] :: Proxy -> Int

-- | All information on how to connect to a host and what should be sent in
--   the HTTP request.
--   
--   If you simply wish to download from a URL, see parseRequest.
--   
--   The constructor for this data type is not exposed. Instead, you should
--   use either the defaultRequest value, or parseRequest
--   to construct from a URL, and then use the records below to make
--   modifications. This approach allows http-client to add configuration
--   options without breaking backwards compatibility.
--   
--   For example, to construct a POST request, you could do something like:
--   
--   
--   initReq <- parseRequest "http://www.example.com/path"
--   let req = initReq
--               { method = "POST"
--               }
--   
--   
--   For more information, please see
--   http://www.yesodweb.com/book/settings-types.
--   
--   Since 0.1.0
data Request

-- | Status of streaming a request body from a file.
--   
--   Since 0.4.9
data StreamFileStatus
StreamFileStatus :: Int64 -> Int64 -> Int -> StreamFileStatus
[fileSize] :: StreamFileStatus -> Int64
[readSoFar] :: StreamFileStatus -> Int64
[thisChunkSize] :: StreamFileStatus -> Int
class HasHttpManager a
getHttpManager :: HasHttpManager a => a -> Manager

-- | Keeps track of open connections for keep-alive.
--   
--   If possible, you should share a single Manager between multiple
--   threads and requests.
--   
--   Since 0.1.0
data Manager

-- | How the HTTP proxy server settings should be discovered.
--   
--   Since 0.4.7
data ProxyOverride

-- | Settings for a Manager. Please use the
--   defaultManagerSettings function and then modify individual
--   settings. For more information, see
--   http://www.yesodweb.com/book/settings-types.
--   
--   Since 0.1.0
data ManagerSettings

-- | A simple representation of the HTTP response.
--   
--   Since 0.1.0
data Response body

-- | How to deal with timing out on retrieval of response headers.
data ResponseTimeout
data HttpExceptionContent

-- | Generated by the parseUrlThrow function when the server
--   returns a non-2XX response status code.
--   
--   May include the beginning of the response body.
StatusCodeException :: Response () -> ByteString -> HttpExceptionContent

-- | The server responded with too many redirects for a request.
--   
--   Contains the list of encountered responses containing redirects in
--   reverse chronological order; including last redirect, which triggered
--   the exception and was not followed.
TooManyRedirects :: [Response ByteString] -> HttpExceptionContent

-- | Too many total bytes in the HTTP header were returned by the server.
OverlongHeaders :: HttpExceptionContent

-- | Too many HTTP header fields were returned by the server.
TooManyHeaderFields :: HttpExceptionContent

-- | The server took too long to return a response. This can be altered via
--   responseTimeout or managerResponseTimeout.
ResponseTimeout :: HttpExceptionContent

-- | Attempting to connect to the server timed out.
ConnectionTimeout :: HttpExceptionContent

-- | An exception occurred when trying to connect to the server.
ConnectionFailure :: SomeException -> HttpExceptionContent

-- | The status line returned by the server could not be parsed.
InvalidStatusLine :: ByteString -> HttpExceptionContent

-- | The given response header line could not be parsed
InvalidHeader :: ByteString -> HttpExceptionContent

-- | The given request header is not compliant (e.g. has newlines)
InvalidRequestHeader :: ByteString -> HttpExceptionContent

-- | An exception was raised by an underlying library when performing the
--   request. Most often, this is caused by a failing socket action or a
--   TLS exception.
InternalException :: SomeException -> HttpExceptionContent

-- | A non-200 status code was returned when trying to connect to the proxy
--   server on the given host and port.
ProxyConnectException :: ByteString -> Int -> Status -> HttpExceptionContent

-- | No response data was received from the server at all. This exception
--   may deserve special handling within the library, since it may indicate
--   that a pipelining has been used, and a connection thought to be open
--   was in fact closed.
NoResponseDataReceived :: HttpExceptionContent

-- | Exception thrown when using a Manager which does not have
--   support for secure connections. Typically, you will want to use
--   tlsManagerSettings from http-client-tls to overcome
--   this.
TlsNotSupported :: HttpExceptionContent

-- | The request body provided did not match the expected size.
--   
--   Provides the expected and actual size.
WrongRequestBodyStreamSize :: Word64 -> Word64 -> HttpExceptionContent

-- | The returned response body is too short. Provides the expected size
--   and actual size.
ResponseBodyTooShort :: Word64 -> Word64 -> HttpExceptionContent

-- | A chunked response body had invalid headers.
InvalidChunkHeaders :: HttpExceptionContent

-- | An incomplete set of response headers were returned.
IncompleteHeaders :: HttpExceptionContent

-- | The host we tried to connect to is invalid (e.g., an empty string).
InvalidDestinationHost :: ByteString -> HttpExceptionContent

-- | An exception was thrown when inflating a response body.
HttpZlibException :: ZlibException -> HttpExceptionContent

-- | Values in the proxy environment variable were invalid. Provides the
--   environment variable name and its value.
InvalidProxyEnvironmentVariable :: Text -> Text -> HttpExceptionContent

-- | Attempted to use a Connection which was already closed
ConnectionClosed :: HttpExceptionContent

-- | Proxy settings are not valid (Windows specific currently) @since 0.5.7
InvalidProxySettings :: Text -> HttpExceptionContent

-- | A function which will provide a Popper to a NeedsPopper.
--   This seemingly convoluted structure allows for creation of request
--   bodies which allocate scarce resources in an exception safe manner.
--   
--   Since 0.1.0
type GivesPopper a = NeedsPopper a -> IO a

-- | A function which must be provided with a Popper.
--   
--   Since 0.1.0
type NeedsPopper a = Popper -> IO a

-- | A function which generates successive chunks of a request body,
--   provider a single empty bytestring when no more data is available.
--   
--   Since 0.1.0
type Popper = IO ByteString

-- | When using one of the RequestBodyStream /
--   RequestBodyStreamChunked constructors, you must ensure that the
--   GivesPopper can be called multiple times. Usually this is not a
--   problem.
--   
--   The RequestBodyStreamChunked will send a chunked request body.
--   Note that not all servers support this. Only use
--   RequestBodyStreamChunked if you know the server you're sending
--   to supports chunked request bodies.
--   
--   Since 0.1.0
data RequestBody
RequestBodyLBS :: ByteString -> RequestBody
RequestBodyBS :: ByteString -> RequestBody
RequestBodyBuilder :: Int64 -> Builder -> RequestBody
RequestBodyStream :: Int64 -> GivesPopper () -> RequestBody
RequestBodyStreamChunked :: GivesPopper () -> RequestBody

-- | Allows creation of a RequestBody inside the IO
--   monad, which is useful for making easier APIs (like
--   setRequestBodyFile).
RequestBodyIO :: IO RequestBody -> RequestBody
data CookieJar
data Cookie
Cookie :: ByteString -> ByteString -> UTCTime -> ByteString -> ByteString -> UTCTime -> UTCTime -> Bool -> Bool -> Bool -> Bool -> Cookie
[cookie_name] :: Cookie -> ByteString
[cookie_value] :: Cookie -> ByteString
[cookie_expiry_time] :: Cookie -> UTCTime
[cookie_domain] :: Cookie -> ByteString
[cookie_path] :: Cookie -> ByteString
[cookie_creation_time] :: Cookie -> UTCTime
[cookie_last_access_time] :: Cookie -> UTCTime
[cookie_persistent] :: Cookie -> Bool
[cookie_host_only] :: Cookie -> Bool
[cookie_secure_only] :: Cookie -> Bool
[cookie_http_only] :: Cookie -> Bool

-- | An exception which may be generated by this library
data HttpException

-- | Most exceptions are specific to a Request. Inspect the
--   HttpExceptionContent value for details on what occurred.
HttpExceptionRequest :: Request -> HttpExceptionContent -> HttpException

-- | A URL (first field) is invalid for a given reason (second argument).
InvalidUrlException :: String -> String -> HttpException

-- | Instead of (==).
--   
--   Since there was some confusion in the history of this library about
--   how the Eq instance should work, it was removed for clarity,
--   and replaced by equal and equiv. equal
--   gives you equality of all fields of the Cookie record.
equalCookie :: Cookie -> Cookie -> Bool

-- | Equality of name, domain, path only. This corresponds to step 11 of
--   the algorithm described in Section 5.3 "Storage Model". See also:
--   equal.
equivCookie :: Cookie -> Cookie -> Bool

-- | Instead of instance Ord Cookie. See equalCookie,
--   equivCookie.
compareCookies :: Cookie -> Cookie -> Ordering

-- | See equalCookie.
equalCookieJar :: CookieJar -> CookieJar -> Bool

-- | See equalCookieJar, equalCookie.
equivCookieJar :: CookieJar -> CookieJar -> Bool

-- | Create a new Connection from a read, write, and close function.
makeConnection :: IO ByteString -> (ByteString -> IO ()) -> IO () -> IO Connection

-- | Create a new Connection from a Socket.
socketConnection :: Socket -> Int -> IO Connection

-- | strippedHostName takes a URI host name, as extracted by
--   regName, and strips square brackets around IPv6 addresses.
--   
--   The result is suitable for passing to services such as name resolution
--   (getAddr).
--   
--   @since
strippedHostName :: String -> String

-- | Continuously call brRead, building up a lazy ByteString until a
--   chunk is constructed that is at least as many bytes as requested.
--   
--   Since 0.4.20
brReadSome :: BodyReader -> Int -> IO ByteString

-- | Deprecated synonym for parseUrlThrow. You probably want
--   parseRequest or parseRequest_ instead.
parseUrl :: MonadThrow m => String -> m Request

-- | Same as parseRequest, except will throw an HttpException
--   in the event of a non-2XX response. This uses
--   throwErrorStatusCodes to implement checkResponse.
parseUrlThrow :: MonadThrow m => String -> m Request

-- | Throws a StatusCodeException wrapped in
--   HttpExceptionRequest, if the response's status code indicates
--   an error (if it isn't 2xx). This can be used to implement
--   checkResponse.
throwErrorStatusCodes :: MonadIO m => Request -> Response BodyReader -> m ()

-- | Convert a URL into a Request.
--   
--   This function defaults some of the values in Request, such as
--   setting method to GET and requestHeaders
--   to [].
--   
--   Since this function uses MonadThrow, the return monad can be
--   anything that is an instance of MonadThrow, such as IO
--   or Maybe.
--   
--   You can place the request method at the beginning of the URL separated
--   by a space, e.g.:
--   
--   
--   parseRequest "POST http://httpbin.org/post"
--   
--   
--   Note that the request method must be provided as all capital letters.
--   
--   A Request created by this function won't cause exceptions on
--   non-2XX response status codes.
--   
--   To create a request which throws on non-2XX status codes, see
--   parseUrlThrow
parseRequest :: MonadThrow m => String -> m Request

-- | Same as parseRequest, but parse errors cause an impure
--   exception. Mostly useful for static strings which are known to be
--   correctly formatted.
parseRequest_ :: String -> Request

-- | Convert a URI into a Request.
--   
--   This can fail if the given URI is not absolute, or if the
--   URI scheme is not "http" or "https". In these
--   cases the function will throw an error via MonadThrow.
--   
--   This function defaults some of the values in Request, such as
--   setting method to GET and requestHeaders
--   to [].
--   
--   A Request created by this function won't cause exceptions on
--   non-2XX response status codes.
requestFromURI :: MonadThrow m => URI -> m Request

-- | Same as requestFromURI, but if the conversion would fail,
--   throws an impure exception.
requestFromURI_ :: URI -> Request

-- | Extract a URI from the request.
--   
--   Since 0.1.0
getUri :: Request -> URI

-- | A default request value, a GET request of localhost/:80, with an empty
--   request body.
--   
--   Note that the default checkResponse does nothing.
defaultRequest :: Request

-- | Add a Basic Auth header (with the specified user name and password) to
--   the given Request. Ignore error handling:
--   
--   
--   applyBasicAuth "user" "pass" $ parseRequest_ url
--   
--   
--   NOTE: The function applyDigestAuth is provided by the
--   http-client-tls package instead of this package due to extra
--   dependencies. Please use that package if you need to use digest
--   authentication.
--   
--   Since 0.1.0
applyBasicAuth :: ByteString -> ByteString -> Request -> Request

-- | Add a Bearer Auth header to the given Request
applyBearerAuth :: ByteString -> Request -> Request

-- | Add a Proxy-Authorization header (with the specified username and
--   password) to the given Request. Ignore error handling:
--   
--   
--   applyBasicProxyAuth "user" "pass" <$> parseRequest "http://example.org"
--   
--   
--   Since 0.3.4
applyBasicProxyAuth :: ByteString -> ByteString -> Request -> Request

-- | Add url-encoded parameters to the Request.
--   
--   This sets a new requestBody, adds a content-type request header
--   and changes the method to POST.
--   
--   Since 0.1.0
urlEncodedBody :: [(ByteString, ByteString)] -> Request -> Request

-- | Modify the request so that non-2XX status codes do not generate a
--   runtime StatusCodeException.
setRequestIgnoreStatus :: Request -> Request

-- | Modify the request so that non-2XX status codes generate a runtime
--   StatusCodeException, by using throwErrorStatusCodes
setRequestCheckStatus :: Request -> Request

-- | Set the query string to the given key/value pairs.
--   
--   Since 0.3.6
setQueryString :: [(ByteString, Maybe ByteString)] -> Request -> Request

-- | Set the query string to the given key/value pairs.
setQueryStringPartialEscape :: [(ByteString, [EscapeItem])] -> Request -> Request

-- | Send a file as the request body.
--   
--   It is expected that the file size does not change between calling
--   streamFile and making any requests using this request body.
--   
--   Since 0.4.9
streamFile :: FilePath -> IO RequestBody

-- | Send a file as the request body, while observing streaming progress
--   via a PopObserver. Observations are made between reading and
--   sending a chunk.
--   
--   It is expected that the file size does not change between calling
--   observedStreamFile and making any requests using this request
--   body.
--   
--   Since 0.4.9
observedStreamFile :: (StreamFileStatus -> IO ()) -> FilePath -> IO RequestBody

-- | Retrieve the orignal Request from a Response
--   
--   Note that the requestBody is not available and always set to
--   empty.
getOriginalRequest :: Response a -> Request

-- | A value for the managerRawConnection setting, but also allows
--   you to modify the underlying Socket to set additional
--   settings. For a motivating use case, see:
--   https://github.com/snoyberg/http-client/issues/71.
--   
--   Since 0.3.8
rawConnectionModifySocket :: (Socket -> IO ()) -> IO (Maybe HostAddress -> String -> Int -> IO Connection)

-- | Same as rawConnectionModifySocket, but also takes in a chunk
--   size.
rawConnectionModifySocketSize :: (Socket -> IO ()) -> IO (Int -> Maybe HostAddress -> String -> Int -> IO Connection)

-- | Create, use and close a Manager.
--   
--   Since 0.2.1
withManager :: ManagerSettings -> (Manager -> IO a) -> IO a

-- | Get the proxy settings from the Request itself.
--   
--   Since 0.4.7
proxyFromRequest :: ProxyOverride

-- | Never connect using a proxy, regardless of the proxy value in the
--   Request.
--   
--   Since 0.4.7
noProxy :: ProxyOverride

-- | Use the given proxy settings, regardless of the proxy value in the
--   Request.
--   
--   Since 0.4.7
useProxy :: Proxy -> ProxyOverride

-- | Send secure requests to the proxy in plain text rather than using
--   CONNECT, regardless of the value in the Request.
useProxySecureWithoutConnect :: Proxy -> ProxyOverride

-- | Get the proxy settings from the default environment variable
--   (http_proxy for insecure, https_proxy for secure).
--   If no variable is set, then fall back to the given value.
--   Nothing is equivalent to noProxy, Just is
--   equivalent to useProxy.
--   
--   Since 0.4.7
proxyEnvironment :: Maybe Proxy -> ProxyOverride

-- | Same as proxyEnvironment, but instead of default environment
--   variable names, allows you to set your own name.
--   
--   Since 0.4.7
proxyEnvironmentNamed :: Text -> Maybe Proxy -> ProxyOverride

-- | The default proxy settings for a manager. In particular: if the
--   http_proxy (or https_proxy) environment variable is
--   set, use it. Otherwise, use the values in the Request.
--   
--   Since 0.4.7
defaultProxy :: ProxyOverride
isIpAddress :: ByteString -> Bool

-- | This corresponds to the subcomponent algorithm entitled "Domain
--   Matching" detailed in section 5.1.3
domainMatches :: ByteString -> ByteString -> Bool

-- | This corresponds to the subcomponent algorithm entitled "Paths"
--   detailed in section 5.1.4
defaultPath :: Request -> ByteString

-- | This corresponds to the subcomponent algorithm entitled "Path-Match"
--   detailed in section 5.1.4
pathMatches :: ByteString -> ByteString -> Bool
createCookieJar :: [Cookie] -> CookieJar
destroyCookieJar :: CookieJar -> [Cookie]
removeExistingCookieFromCookieJar :: Cookie -> CookieJar -> (Maybe Cookie, CookieJar)

-- | Algorithm described in "Secure Contexts", Section 3.1, "Is origin
--   potentially trustworthy?"
--   
--   Note per RFC6265 section 5.4 user agent is free to define the meaning
--   of "secure" protocol.
--   
--   See:
--   https://w3c.github.io/webappsec-secure-contexts/#is-origin-trustworthy
isPotentiallyTrustworthyOrigin :: Bool -> ByteString -> Bool

-- | This corresponds to the eviction algorithm described in Section 5.3
--   "Storage Model"
evictExpiredCookies :: CookieJar -> UTCTime -> CookieJar

-- | This applies the computeCookieString to a given Request
insertCookiesIntoRequest :: Request -> CookieJar -> UTCTime -> (Request, CookieJar)

-- | This corresponds to the algorithm described in Section 5.4 "The Cookie
--   Header"
computeCookieString :: Request -> CookieJar -> UTCTime -> Bool -> (ByteString, CookieJar)

-- | This applies receiveSetCookie to a given Response
updateCookieJar :: Response a -> Request -> UTCTime -> CookieJar -> (CookieJar, Response a)

-- | This corresponds to the algorithm described in Section 5.3 "Storage
--   Model" This function consists of calling generateCookie
--   followed by insertCheckedCookie. Use this function if you plan
--   to do both in a row. generateCookie and
--   insertCheckedCookie are only provided for more fine-grained
--   control.
receiveSetCookie :: SetCookie -> Request -> UTCTime -> Bool -> CookieJar -> CookieJar

-- | Insert a cookie created by generateCookie into the cookie jar (or not
--   if it shouldn't be allowed in)
insertCheckedCookie :: Cookie -> CookieJar -> Bool -> CookieJar

-- | Turn a SetCookie into a Cookie, if it is valid
generateCookie :: SetCookie -> Request -> UTCTime -> Bool -> Maybe Cookie

-- | Perform an action using a Connection acquired from the given
--   Manager.
--   
--   You should use this only when you have to read and write interactively
--   through the connection (e.g. connection by the WebSocket protocol).
withConnection :: Request -> Manager -> (Connection -> IO a) -> IO a

-- | A datatype holding information on redirected requests and the final
--   response.
--   
--   Since 0.4.1
data HistoriedResponse body

-- | A variant of responseOpen which keeps a history of all
--   redirects performed in the interim, together with the first 1024 bytes
--   of their response bodies.
--   
--   Since 0.4.1
responseOpenHistory :: Request -> Manager -> IO (HistoriedResponse BodyReader)

-- | A variant of withResponse which keeps a history of all
--   redirects performed in the interim, together with the first 1024 bytes
--   of their response bodies.
--   
--   Since 0.4.1
withResponseHistory :: Request -> Manager -> (HistoriedResponse BodyReader -> IO a) -> IO a

-- | Set the proxy override value, only for HTTP (insecure) connections.
--   
--   Since 0.4.7
managerSetInsecureProxy :: ProxyOverride -> ManagerSettings -> ManagerSettings

-- | Set the proxy override value, only for HTTPS (secure) connections.
--   
--   Since 0.4.7
managerSetSecureProxy :: ProxyOverride -> ManagerSettings -> ManagerSettings

-- | Set the proxy override value, for both HTTP (insecure) and HTTPS
--   (insecure) connections.
--   
--   Since 0.4.7
managerSetProxy :: ProxyOverride -> ManagerSettings -> ManagerSettings
managerSetMaxHeaderLength :: Int -> ManagerSettings -> ManagerSettings
managerSetMaxNumberHeaders :: Int -> ManagerSettings -> ManagerSettings

-- | Specify maximum time in microseconds the retrieval of response headers
--   is allowed to take
responseTimeoutMicro :: Int -> ResponseTimeout

-- | Do not have a response timeout
responseTimeoutNone :: ResponseTimeout

-- | Use the default response timeout
--   
--   When used on a Request, means: use the manager's timeout value
--   
--   When used on a ManagerSettings, means: default to 30 seconds
responseTimeoutDefault :: ResponseTimeout

-- | Same as httpLbs, except it uses the Manager in the
--   reader environment.
--   
--   Since 2.1.1
httpLbs :: (MonadIO m, HasHttpManager env, MonadReader env m) => Request -> m (Response ByteString)

-- | 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
httpNoBody :: (MonadIO m, HasHttpManager env, MonadReader env m) => Request -> m (Response ())
requestBodySource :: Int64 -> ConduitM () ByteString IO () -> RequestBody
requestBodySourceChunked :: ConduitM () ByteString IO () -> RequestBody
bodyReaderSource :: forall (m :: Type -> Type) i. MonadIO m => BodyReader -> ConduitM i ByteString m ()

-- | 
Simpler API
--   
--   The API below is rather low-level. The Network.HTTP.Simple
--   module provides a higher-level API with built-in support for things
--   like JSON request and response bodies. For most users, this will be an
--   easier place to start. You can read the tutorial at:
--   
--   https://haskell-lang.org/library/http-client
--   
--   
Lower-level API
--   
--   This module contains everything you need to initiate HTTP connections.
--   If you want a simple interface based on URLs, you can use
--   simpleHttp. If you want raw power, http is the
--   underlying workhorse of this package. Some examples:
--   
--   
--   -- Just download an HTML document and print it.
--   import Network.HTTP.Conduit
--   import qualified Data.ByteString.Lazy as L
--   
--   main = simpleHttp "http://www.haskell.org/" >>= L.putStr
--   
--   
--   This example uses interleaved IO to write the response body to a file
--   in constant memory space.
--   
--   
--   import Data.Conduit.Binary (sinkFile) -- Exported from the package conduit-extra
--   import Network.HTTP.Conduit
--   import Conduit (runConduit, (.|))
--   import Control.Monad.Trans.Resource (runResourceT)
--   
--   main :: IO ()
--   main = do
--        request <- parseRequest "http://google.com/"
--        manager <- newManager tlsManagerSettings
--        runResourceT $ do
--            response <- http request manager
--            runConduit $ responseBody response .| sinkFile "google.html"
--   
--   
--   The following headers are automatically set by this module, and should
--   not be added to requestHeaders:
--   
--   
--   
- Cookie
--   
- Content-Length
--   
- Transfer-Encoding
--   
--   
--   Note: In previous versions, the Host header would be set by this
--   module in all cases. Starting from 1.6.1, if a Host header is present
--   in requestHeaders, it will be used in place of the header
--   this module would have generated. This can be useful for calling a
--   server which utilizes virtual hosting.
--   
--   Use cookieJar If you want to supply cookies with your request:
--   
--   
--   {-# LANGUAGE OverloadedStrings #-}
--   import Network.HTTP.Conduit
--   import Network
--   import Data.Time.Clock
--   import Data.Time.Calendar
--   import qualified Control.Exception as E
--   import Network.HTTP.Types.Status (statusCode)
--   
--   past :: UTCTime
--   past = UTCTime (ModifiedJulianDay 56200) (secondsToDiffTime 0)
--   
--   future :: UTCTime
--   future = UTCTime (ModifiedJulianDay 562000) (secondsToDiffTime 0)
--   
--   cookie :: Cookie
--   cookie = Cookie { cookie_name = "password_hash"
--                   , cookie_value = "abf472c35f8297fbcabf2911230001234fd2"
--                   , cookie_expiry_time = future
--                   , cookie_domain = "example.com"
--                   , cookie_path = "/"
--                   , cookie_creation_time = past
--                   , cookie_last_access_time = past
--                   , cookie_persistent = False
--                   , cookie_host_only = False
--                   , cookie_secure_only = False
--                   , cookie_http_only = False
--                   }
--   
--   main = do
--        request' <- parseRequest "http://example.com/secret-page"
--        manager <- newManager tlsManagerSettings
--        let request = request' { cookieJar = Just $ createCookieJar [cookie] }
--        fmap Just (httpLbs request manager) `E.catch`
--                (\ex -> case ex of
--                    HttpExceptionRequest _ (StatusCodeException res _) ->
--                        if statusCode (responseStatus res) == 403
--                          then (putStrLn "login failed" >> return Nothing)
--                          else return Nothing
--                    _ -> E.throw ex)
--   
--   
--   Cookies are implemented according to RFC 6265.
--   
--   Note that by default, the functions in this package will throw
--   exceptions for non-2xx status codes. If you would like to avoid this,
--   you should use checkStatus, e.g.:
--   
--   
--   import Data.Conduit.Binary (sinkFile)
--   import Network.HTTP.Conduit
--   import qualified Data.Conduit as C
--   import Network
--   
--   main :: IO ()
--   main = do
--        request' <- parseRequest "http://www.yesodweb.com/does-not-exist"
--        let request = request' { checkStatus = \_ _ _ -> Nothing }
--        manager <- newManager tlsManagerSettings
--        res <- httpLbs request manager
--        print res
--   
--   
--   By default, when connecting to websites using HTTPS, functions in this
--   package will throw an exception if the TLS certificate doesn't
--   validate. To continue the HTTPS transaction even if the TLS cerficate
--   validation fails, you should use mkManagerSetttings as
--   follows:
--   
--   
--   import Network.Connection (TLSSettings (..))
--   import Network.HTTP.Conduit
--   
--   main :: IO ()
--   main = do
--       request <- parseRequest "https://github.com/"
--       let settings = mkManagerSettings (TLSSettingsSimple True False False) Nothing
--       manager <- newManager settings
--       res <- httpLbs request manager
--       print res
--   
--   
--   For more information, please be sure to read the documentation in the
--   Network.HTTP.Client module.
module Network.HTTP.Conduit

-- | 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.
simpleHttp :: MonadIO m => String -> m ByteString

-- | 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.
httpLbs :: MonadIO m => Request -> Manager -> m (Response ByteString)
http :: MonadResource m => Request -> Manager -> m (Response (ConduitM i ByteString m ()))

-- | Define a HTTP proxy, consisting of a hostname and port number.
data Proxy
Proxy :: ByteString -> Int -> Proxy

-- | The host name of the HTTP proxy in URI format. IPv6 addresses in
--   square brackets.
[proxyHost] :: Proxy -> ByteString

-- | The port number of the HTTP proxy.
[proxyPort] :: Proxy -> Int

-- | When using one of the RequestBodyStream /
--   RequestBodyStreamChunked constructors, you must ensure that the
--   GivesPopper can be called multiple times. Usually this is not a
--   problem.
--   
--   The RequestBodyStreamChunked will send a chunked request body.
--   Note that not all servers support this. Only use
--   RequestBodyStreamChunked if you know the server you're sending
--   to supports chunked request bodies.
--   
--   Since 0.1.0
data RequestBody
RequestBodyLBS :: ByteString -> RequestBody
RequestBodyBS :: ByteString -> RequestBody
RequestBodyBuilder :: Int64 -> Builder -> RequestBody
RequestBodyStream :: Int64 -> GivesPopper () -> RequestBody
RequestBodyStreamChunked :: GivesPopper () -> RequestBody

-- | Allows creation of a RequestBody inside the IO
--   monad, which is useful for making easier APIs (like
--   setRequestBodyFile).
RequestBodyIO :: IO RequestBody -> RequestBody

-- | All information on how to connect to a host and what should be sent in
--   the HTTP request.
--   
--   If you simply wish to download from a URL, see parseRequest.
--   
--   The constructor for this data type is not exposed. Instead, you should
--   use either the defaultRequest value, or parseRequest
--   to construct from a URL, and then use the records below to make
--   modifications. This approach allows http-client to add configuration
--   options without breaking backwards compatibility.
--   
--   For example, to construct a POST request, you could do something like:
--   
--   
--   initReq <- parseRequest "http://www.example.com/path"
--   let req = initReq
--               { method = "POST"
--               }
--   
--   
--   For more information, please see
--   http://www.yesodweb.com/book/settings-types.
--   
--   Since 0.1.0
data Request

-- | HTTP request method, eg GET, POST.
--   
--   Since 0.1.0
method :: Request -> Method

-- | Whether to use HTTPS (ie, SSL).
--   
--   Since 0.1.0
secure :: Request -> Bool

-- | Requested host name, used for both the IP address to connect to and
--   the host request header.
--   
--   This is in URI format, with raw IPv6 addresses enclosed in square
--   brackets. Use strippedHostName when making network
--   connections.
--   
--   Since 0.1.0
host :: Request -> ByteString

-- | The port to connect to. Also used for generating the host
--   request header.
--   
--   Since 0.1.0
port :: Request -> Int

-- | Everything from the host to the query string.
--   
--   Since 0.1.0
path :: Request -> ByteString

-- | Query string appended to the path.
--   
--   Since 0.1.0
queryString :: Request -> ByteString

-- | Custom HTTP request headers
--   
--   The Content-Length and Transfer-Encoding headers are set automatically
--   by this module, and shall not be added to requestHeaders.
--   
--   If not provided by the user, Host will automatically be set
--   based on the host and port fields.
--   
--   Moreover, the Accept-Encoding header is set implicitly to gzip for
--   convenience by default. This behaviour can be overridden if needed, by
--   setting the header explicitly to a different value. In order to omit
--   the Accept-Header altogether, set it to the empty string "". If you
--   need an empty Accept-Header (i.e. requesting the identity encoding),
--   set it to a non-empty white-space string, e.g. " ". See RFC 2616
--   section 14.3 for details about the semantics of the Accept-Header
--   field. If you request a content-encoding not supported by this module,
--   you will have to decode it yourself (see also the decompress
--   field).
--   
--   Note: Multiple header fields with the same field-name will result in
--   multiple header fields being sent and therefore it's the
--   responsibility of the client code to ensure that the rules from RFC
--   2616 section 4.2 are honoured.
--   
--   Since 0.1.0
requestHeaders :: Request -> RequestHeaders

-- | Request body to be sent to the server.
--   
--   Since 0.1.0
requestBody :: Request -> RequestBody

-- | Optional HTTP proxy.
--   
--   Since 0.1.0
proxy :: Request -> Maybe Proxy

-- | Optional resolved host address. May not be used by all backends.
--   
--   Since 0.1.0
hostAddress :: Request -> Maybe HostAddress

-- | If True, a chunked and/or gzipped body will not be decoded.
--   Use with caution.
--   
--   Since 0.1.0
rawBody :: Request -> Bool

-- | Predicate to specify whether gzipped data should be decompressed on
--   the fly (see alwaysDecompress and
--   browserDecompress). Argument is the mime type. Default:
--   browserDecompress.
--   
--   Since 0.1.0
decompress :: Request -> ByteString -> Bool

-- | How many redirects to follow when getting a resource. 0 means follow
--   no redirects. Default value: 10.
--   
--   Since 0.1.0
redirectCount :: Request -> Int

-- | Decide whether a header must be stripped from the request when
--   following a redirect. Default: keep all headers intact.
shouldStripHeaderOnRedirect :: Request -> HeaderName -> Bool

-- | Check the response immediately after receiving the status and headers.
--   This can be useful for throwing exceptions on non-success status
--   codes.
--   
--   In previous versions of http-client, this went under the name
--   checkStatus, but was renamed to avoid confusion about the new
--   default behavior (doing nothing).
checkResponse :: Request -> Request -> Response BodyReader -> IO ()

-- | Number of microseconds to wait for a response (see
--   ResponseTimeout for more information). Default: use
--   managerResponseTimeout (which by default is 30 seconds).
--   
--   Since 0.1.0
responseTimeout :: Request -> ResponseTimeout

-- | A user-defined cookie jar. If Nothing, no cookie handling will
--   take place, "Cookie" headers in requestHeaders will be sent
--   raw, and responseCookieJar will be empty.
--   
--   Since 0.1.0
cookieJar :: Request -> Maybe CookieJar

-- | HTTP version to send to server.
--   
--   Default: HTTP 1.1
--   
--   Since 0.4.3
requestVersion :: Request -> HttpVersion

-- | Set the query string to the given key/value pairs.
--   
--   Since 0.3.6
setQueryString :: [(ByteString, Maybe ByteString)] -> Request -> Request
requestBodySource :: Int64 -> ConduitM () ByteString (ResourceT IO) () -> RequestBody
requestBodySourceChunked :: ConduitM () ByteString (ResourceT IO) () -> RequestBody
requestBodySourceIO :: Int64 -> ConduitM () ByteString IO () -> RequestBody
requestBodySourceChunkedIO :: ConduitM () ByteString IO () -> RequestBody

-- | A simple representation of the HTTP response.
--   
--   Since 0.1.0
data Response body

-- | Status code of the response.
--   
--   Since 0.1.0
responseStatus :: Response body -> Status

-- | HTTP version used by the server.
--   
--   Since 0.1.0
responseVersion :: Response body -> HttpVersion

-- | Response headers sent by the server.
--   
--   Since 0.1.0
responseHeaders :: Response body -> ResponseHeaders

-- | Response body sent by the server.
--   
--   Since 0.1.0
responseBody :: Response body -> body

-- | Cookies set on the client after interacting with the server. If
--   cookies have been disabled by setting cookieJar to
--   Nothing, then this will always be empty.
--   
--   Since 0.1.0
responseCookieJar :: Response body -> CookieJar

-- | Early response headers sent by the server, as part of an HTTP 103
--   Early Hints section.
--   
--   Since 0.7.16
responseEarlyHints :: Response body -> ResponseHeaders

-- | Keeps track of open connections for keep-alive.
--   
--   If possible, you should share a single Manager between multiple
--   threads and requests.
--   
--   Since 0.1.0
data Manager

-- | Create a Manager. The Manager will be shut down
--   automatically via garbage collection.
--   
--   Creating a new Manager is a relatively expensive operation, you
--   are advised to share a single Manager between requests instead.
--   
--   The first argument to this function is often
--   defaultManagerSettings, though add-on libraries may provide a
--   recommended replacement.
--   
--   Since 0.1.0
newManager :: ManagerSettings -> IO Manager

-- | Close all connections in a Manager.
--   
--   Note that this doesn't affect currently in-flight connections, meaning
--   you can safely use it without hurting any queries you may have
--   concurrently running.
--   
--   Since 0.1.0
closeManager :: Manager -> IO ()

-- | Settings for a Manager. Please use the
--   defaultManagerSettings function and then modify individual
--   settings. For more information, see
--   http://www.yesodweb.com/book/settings-types.
--   
--   Since 0.1.0
data ManagerSettings

-- | Default TLS-enabled manager settings
tlsManagerSettings :: ManagerSettings

-- | Create a TLS-enabled ManagerSettings with the given
--   TLSSettings and SockSettings
mkManagerSettings :: TLSSettings -> Maybe SockSettings -> ManagerSettings

-- | Number of connections to a single host to keep alive. Default: 10.
--   
--   Since 0.1.0
managerConnCount :: ManagerSettings -> Int

-- | Default timeout to be applied to requests which do not provide a
--   timeout value.
--   
--   Default is 30 seconds
managerResponseTimeout :: ManagerSettings -> ResponseTimeout

-- | Create a TLS connection. Default behavior: throw an exception that TLS
--   is not supported.
--   
--   Since 0.1.0
managerTlsConnection :: ManagerSettings -> IO (Maybe HostAddress -> String -> Int -> IO Connection)

-- | How to deal with timing out on retrieval of response headers.
data ResponseTimeout

-- | Specify maximum time in microseconds the retrieval of response headers
--   is allowed to take
responseTimeoutMicro :: Int -> ResponseTimeout

-- | Do not have a response timeout
responseTimeoutNone :: ResponseTimeout

-- | Use the default response timeout
--   
--   When used on a Request, means: use the manager's timeout value
--   
--   When used on a ManagerSettings, means: default to 30 seconds
responseTimeoutDefault :: ResponseTimeout
data Cookie
Cookie :: ByteString -> ByteString -> UTCTime -> ByteString -> ByteString -> UTCTime -> UTCTime -> Bool -> Bool -> Bool -> Bool -> Cookie
[cookie_name] :: Cookie -> ByteString
[cookie_value] :: Cookie -> ByteString
[cookie_expiry_time] :: Cookie -> UTCTime
[cookie_domain] :: Cookie -> ByteString
[cookie_path] :: Cookie -> ByteString
[cookie_creation_time] :: Cookie -> UTCTime
[cookie_last_access_time] :: Cookie -> UTCTime
[cookie_persistent] :: Cookie -> Bool
[cookie_host_only] :: Cookie -> Bool
[cookie_secure_only] :: Cookie -> Bool
[cookie_http_only] :: Cookie -> Bool
data CookieJar
createCookieJar :: [Cookie] -> CookieJar
destroyCookieJar :: CookieJar -> [Cookie]

-- | Deprecated synonym for parseUrlThrow. You probably want
--   parseRequest or parseRequest_ instead.
parseUrl :: MonadThrow m => String -> m Request

-- | Same as parseRequest, except will throw an HttpException
--   in the event of a non-2XX response. This uses
--   throwErrorStatusCodes to implement checkResponse.
parseUrlThrow :: MonadThrow m => String -> m Request

-- | Convert a URL into a Request.
--   
--   This function defaults some of the values in Request, such as
--   setting method to GET and requestHeaders
--   to [].
--   
--   Since this function uses MonadThrow, the return monad can be
--   anything that is an instance of MonadThrow, such as IO
--   or Maybe.
--   
--   You can place the request method at the beginning of the URL separated
--   by a space, e.g.:
--   
--   
--   parseRequest "POST http://httpbin.org/post"
--   
--   
--   Note that the request method must be provided as all capital letters.
--   
--   A Request created by this function won't cause exceptions on
--   non-2XX response status codes.
--   
--   To create a request which throws on non-2XX status codes, see
--   parseUrlThrow
parseRequest :: MonadThrow m => String -> m Request

-- | Same as parseRequest, but parse errors cause an impure
--   exception. Mostly useful for static strings which are known to be
--   correctly formatted.
parseRequest_ :: String -> Request

-- | A default request value, a GET request of localhost/:80, with an empty
--   request body.
--   
--   Note that the default checkResponse does nothing.
defaultRequest :: Request

-- | Add a Basic Auth header (with the specified user name and password) to
--   the given Request. Ignore error handling:
--   
--   
--   applyBasicAuth "user" "pass" $ parseRequest_ url
--   
--   
--   NOTE: The function applyDigestAuth is provided by the
--   http-client-tls package instead of this package due to extra
--   dependencies. Please use that package if you need to use digest
--   authentication.
--   
--   Since 0.1.0
applyBasicAuth :: ByteString -> ByteString -> Request -> Request

-- | Add a proxy to the Request so that the Request when executed will use
--   the provided proxy.
--   
--   Since 0.1.0
addProxy :: ByteString -> Int -> Request -> Request
lbsResponse :: Monad m => Response (ConduitM () ByteString m ()) -> m (Response ByteString)

-- | If a request is a redirection (status code 3xx) this function will
--   create a new request from the old request, the server headers returned
--   with the redirection, and the redirection code itself. This function
--   returns Nothing if the code is not a 3xx, there is no
--   location header included, or if the redirected response
--   couldn't be parsed with parseRequest.
--   
--   If a user of this library wants to know the url chain that results
--   from a specific request, that user has to re-implement the
--   redirect-following logic themselves. An example of that might look
--   like this:
--   
--   
--   myHttp req man = do
--      (res, redirectRequests) <- (`runStateT` []) $
--           'httpRedirect'
--               9000
--               (\req' -> do
--                  res <- http req'{redirectCount=0} man
--                  modify (\rqs -> req' : rqs)
--                  return (res, getRedirectedRequest req req' (responseHeaders res) (responseCookieJar res) (W.statusCode (responseStatus res))
--                  )
--               'lift'
--               req
--      applyCheckStatus (checkStatus req) res
--      return redirectRequests
--   
getRedirectedRequest :: Request -> Request -> ResponseHeaders -> CookieJar -> Int -> Maybe Request

-- | Always decompress a compressed stream.
alwaysDecompress :: ByteString -> Bool

-- | Decompress a compressed stream unless the content-type is
--   'application/x-tar'.
browserDecompress :: ByteString -> Bool

-- | Add url-encoded parameters to the Request.
--   
--   This sets a new requestBody, adds a content-type request header
--   and changes the method to POST.
--   
--   Since 0.1.0
urlEncodedBody :: [(ByteString, ByteString)] -> Request -> Request

-- | An exception which may be generated by this library
data HttpException

-- | Most exceptions are specific to a Request. Inspect the
--   HttpExceptionContent value for details on what occurred.
HttpExceptionRequest :: Request -> HttpExceptionContent -> HttpException

-- | A URL (first field) is invalid for a given reason (second argument).
InvalidUrlException :: String -> String -> HttpException
data HttpExceptionContent

-- | Generated by the parseUrlThrow function when the server
--   returns a non-2XX response status code.
--   
--   May include the beginning of the response body.
StatusCodeException :: Response () -> ByteString -> HttpExceptionContent

-- | The server responded with too many redirects for a request.
--   
--   Contains the list of encountered responses containing redirects in
--   reverse chronological order; including last redirect, which triggered
--   the exception and was not followed.
TooManyRedirects :: [Response ByteString] -> HttpExceptionContent

-- | Too many total bytes in the HTTP header were returned by the server.
OverlongHeaders :: HttpExceptionContent

-- | Too many HTTP header fields were returned by the server.
TooManyHeaderFields :: HttpExceptionContent

-- | The server took too long to return a response. This can be altered via
--   responseTimeout or managerResponseTimeout.
ResponseTimeout :: HttpExceptionContent

-- | Attempting to connect to the server timed out.
ConnectionTimeout :: HttpExceptionContent

-- | An exception occurred when trying to connect to the server.
ConnectionFailure :: SomeException -> HttpExceptionContent

-- | The status line returned by the server could not be parsed.
InvalidStatusLine :: ByteString -> HttpExceptionContent

-- | The given response header line could not be parsed
InvalidHeader :: ByteString -> HttpExceptionContent

-- | The given request header is not compliant (e.g. has newlines)
InvalidRequestHeader :: ByteString -> HttpExceptionContent

-- | An exception was raised by an underlying library when performing the
--   request. Most often, this is caused by a failing socket action or a
--   TLS exception.
InternalException :: SomeException -> HttpExceptionContent

-- | A non-200 status code was returned when trying to connect to the proxy
--   server on the given host and port.
ProxyConnectException :: ByteString -> Int -> Status -> HttpExceptionContent

-- | No response data was received from the server at all. This exception
--   may deserve special handling within the library, since it may indicate
--   that a pipelining has been used, and a connection thought to be open
--   was in fact closed.
NoResponseDataReceived :: HttpExceptionContent

-- | Exception thrown when using a Manager which does not have
--   support for secure connections. Typically, you will want to use
--   tlsManagerSettings from http-client-tls to overcome
--   this.
TlsNotSupported :: HttpExceptionContent

-- | The request body provided did not match the expected size.
--   
--   Provides the expected and actual size.
WrongRequestBodyStreamSize :: Word64 -> Word64 -> HttpExceptionContent

-- | The returned response body is too short. Provides the expected size
--   and actual size.
ResponseBodyTooShort :: Word64 -> Word64 -> HttpExceptionContent

-- | A chunked response body had invalid headers.
InvalidChunkHeaders :: HttpExceptionContent

-- | An incomplete set of response headers were returned.
IncompleteHeaders :: HttpExceptionContent

-- | The host we tried to connect to is invalid (e.g., an empty string).
InvalidDestinationHost :: ByteString -> HttpExceptionContent

-- | An exception was thrown when inflating a response body.
HttpZlibException :: ZlibException -> HttpExceptionContent

-- | Values in the proxy environment variable were invalid. Provides the
--   environment variable name and its value.
InvalidProxyEnvironmentVariable :: Text -> Text -> HttpExceptionContent

-- | Attempted to use a Connection which was already closed
ConnectionClosed :: HttpExceptionContent

-- | Proxy settings are not valid (Windows specific currently) @since 0.5.7
InvalidProxySettings :: Text -> HttpExceptionContent

-- | Simplified interface for common HTTP client interactions. Tutorial
--   available at https://haskell-lang.org/library/http-client
--   
--   Important note: Request is an instance of IsString, and
--   therefore recommended usage is to turn on OverloadedStrings,
--   e.g.
--   
--   
--   {-# LANGUAGE OverloadedStrings #-}
--   import Network.HTTP.Simple
--   import qualified Data.ByteString.Char8 as B8
--   
--   main :: IO ()
--   main = httpBS "http://example.com" >>= B8.putStrLn . getResponseBody
--   
--   
--   The IsString instance uses parseRequest behind the
--   scenes and inherits its behavior.
module Network.HTTP.Simple

-- | Perform an HTTP request and return the body as a ByteString.
httpBS :: MonadIO m => Request -> m (Response ByteString)

-- | 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.
httpLBS :: MonadIO m => Request -> m (Response ByteString)

-- | Perform an HTTP request and ignore the response body.
httpNoBody :: MonadIO m => Request -> m (Response ())

-- | 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
httpJSON :: (MonadIO m, FromJSON a) => Request -> m (Response a)

-- | 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
httpJSONEither :: (MonadIO m, FromJSON a) => Request -> m (Response (Either JSONException a))

-- | Perform an HTTP request and consume the body with the given
--   Sink
httpSink :: MonadUnliftIO m => Request -> (Response () -> ConduitM ByteString Void m a) -> m a

-- | 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
--   
httpSource :: forall (m :: Type -> Type) (n :: Type -> Type) i o r. (MonadResource m, MonadIO n) => Request -> (Response (ConduitM i ByteString n ()) -> ConduitM i o m r) -> ConduitM i o m r

-- | Perform an action with the given request. This employes the bracket
--   pattern.
--   
--   This is similar to httpSource, but does not require
--   MonadResource and allows the result to not contain a
--   ConduitM value.
withResponse :: forall m (n :: Type -> Type) i a. (MonadUnliftIO m, MonadIO n) => Request -> (Response (ConduitM i ByteString n ()) -> m a) -> m a

-- | A full HTTP header field with the name and value separated.
--   
--   E.g. "Content-Length: 28" parsed into a Header would
--   turn into ("Content-Length", "28")
type Header = (HeaderName, ByteString)

-- | A sequence of QueryItems.
type Query = [QueryItem]

-- | An item from the query string, split up into two parts.
--   
--   The second part should be Nothing if there was no key-value
--   separator after the query item name.
type QueryItem = (ByteString, Maybe ByteString)

-- | All information on how to connect to a host and what should be sent in
--   the HTTP request.
--   
--   If you simply wish to download from a URL, see parseRequest.
--   
--   The constructor for this data type is not exposed. Instead, you should
--   use either the defaultRequest value, or parseRequest
--   to construct from a URL, and then use the records below to make
--   modifications. This approach allows http-client to add configuration
--   options without breaking backwards compatibility.
--   
--   For example, to construct a POST request, you could do something like:
--   
--   
--   initReq <- parseRequest "http://www.example.com/path"
--   let req = initReq
--               { method = "POST"
--               }
--   
--   
--   For more information, please see
--   http://www.yesodweb.com/book/settings-types.
--   
--   Since 0.1.0
data Request

-- | A list of Headers.
--   
--   Same type as ResponseHeaders, but useful to differentiate in
--   type signatures.
type RequestHeaders = [Header]

-- | A simple representation of the HTTP response.
--   
--   Since 0.1.0
data Response body

-- | A list of Headers.
--   
--   Same type as RequestHeaders, but useful to differentiate in
--   type signatures.
type ResponseHeaders = [Header]

-- | An exception that can occur when parsing JSON
--   
--   NOTE: Depends on the aeson cabal flag being enabled
data JSONException
JSONParseException :: Request -> Response () -> ParseError -> JSONException
JSONConversionException :: Request -> Response Value -> String -> JSONException

-- | An exception which may be generated by this library
data HttpException

-- | Most exceptions are specific to a Request. Inspect the
--   HttpExceptionContent value for details on what occurred.
HttpExceptionRequest :: Request -> HttpExceptionContent -> HttpException

-- | A URL (first field) is invalid for a given reason (second argument).
InvalidUrlException :: String -> String -> HttpException

-- | Define a HTTP proxy, consisting of a hostname and port number.
data Proxy
Proxy :: ByteString -> Int -> Proxy

-- | The host name of the HTTP proxy in URI format. IPv6 addresses in
--   square brackets.
[proxyHost] :: Proxy -> ByteString

-- | The port number of the HTTP proxy.
[proxyPort] :: Proxy -> Int

-- | A default request value, a GET request of localhost/:80, with an empty
--   request body.
--   
--   Note that the default checkResponse does nothing.
defaultRequest :: Request

-- | Convert a URL into a Request.
--   
--   This function defaults some of the values in Request, such as
--   setting method to GET and requestHeaders
--   to [].
--   
--   Since this function uses MonadThrow, the return monad can be
--   anything that is an instance of MonadThrow, such as IO
--   or Maybe.
--   
--   You can place the request method at the beginning of the URL separated
--   by a space, e.g.:
--   
--   
--   parseRequest "POST http://httpbin.org/post"
--   
--   
--   Note that the request method must be provided as all capital letters.
--   
--   A Request created by this function won't cause exceptions on
--   non-2XX response status codes.
--   
--   To create a request which throws on non-2XX status codes, see
--   parseUrlThrow
parseRequest :: MonadThrow m => String -> m Request

-- | Same as parseRequest, but parse errors cause an impure
--   exception. Mostly useful for static strings which are known to be
--   correctly formatted.
parseRequest_ :: String -> Request

-- | Same as parseRequest, except will throw an
--   HttpException in the event of a non-2XX response. This uses
--   throwErrorStatusCodes to implement checkResponse.
--   
--   Exactly the same as parseUrlThrow, but has a name that is
--   more consistent with the other parseRequest functions.
parseRequestThrow :: MonadThrow m => String -> m Request

-- | Same as parseRequestThrow, but parse errors cause an impure
--   exception. Mostly useful for static strings which are known to be
--   correctly formatted.
parseRequestThrow_ :: String -> Request

-- | Set the request method
setRequestMethod :: ByteString -> Request -> Request

-- | Set whether this is a secureHTTPS (True) or
--   insecureHTTP (False) request
setRequestSecure :: Bool -> Request -> Request

-- | Set the destination host of the request
setRequestHost :: ByteString -> Request -> Request

-- | Set the destination port of the request
setRequestPort :: Int -> Request -> Request

-- | Lens for the requested path info of the request
setRequestPath :: ByteString -> Request -> Request

-- | Add a request header name/value combination
addRequestHeader :: HeaderName -> ByteString -> Request -> Request

-- | Get all request header values for the given name
getRequestHeader :: HeaderName -> Request -> [ByteString]

-- | Set the given request header to the given list of values. Removes any
--   previously set header values with the same name.
setRequestHeader :: HeaderName -> [ByteString] -> Request -> Request

-- | Set the request headers, wiping out all previously set headers.
--   This means if you use setRequestHeaders to set some headers and
--   also use one of the other setters that modifies the
--   content-type header (such as setRequestBodyJSON), be
--   sure that setRequestHeaders is evaluated first.
setRequestHeaders :: RequestHeaders -> Request -> Request

-- | Set the query string parameters
setRequestQueryString :: Query -> Request -> Request

-- | Get the query string parameters
getRequestQueryString :: Request -> Query

-- | Add to the existing query string parameters.
addToRequestQueryString :: Query -> Request -> Request

-- | Set the request body to the given RequestBody. You may want to
--   consider using one of the convenience functions in the modules, e.g.
--   requestBodyJSON.
--   
--   Note: This will not modify the request method. For that, please
--   use requestMethod. You likely don't want the default of
--   GET.
setRequestBody :: RequestBody -> Request -> Request

-- | Set the request body as a JSON value
--   
--   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;
--   charset=utf-8
--   
--   NOTE: Depends on the aeson cabal flag being enabled
setRequestBodyJSON :: ToJSON a => a -> Request -> Request

-- | Set the request body as a lazy ByteString
--   
--   Note: This will not modify the request method. For that, please
--   use requestMethod. You likely don't want the default of
--   GET.
setRequestBodyLBS :: ByteString -> Request -> Request

-- | Set the request body as a Source
--   
--   Note: This will not modify the request method. For that, please
--   use requestMethod. You likely don't want the default of
--   GET.
setRequestBodySource :: Int64 -> ConduitM () ByteString IO () -> Request -> Request

-- | Set the request body as a file
--   
--   Note: This will not modify the request method. For that, please
--   use requestMethod. You likely don't want the default of
--   GET.
setRequestBodyFile :: FilePath -> Request -> Request

-- | Set the request body as URL encoded data
--   
--   Note: This will change the request method to POST and
--   set the content-type to
--   application/x-www-form-urlencoded
setRequestBodyURLEncoded :: [(ByteString, ByteString)] -> Request -> Request

-- | Modify the request so that non-2XX status codes do not generate a
--   runtime StatusCodeException.
setRequestIgnoreStatus :: Request -> Request

-- | Modify the request so that non-2XX status codes generate a runtime
--   StatusCodeException, by using throwErrorStatusCodes
setRequestCheckStatus :: Request -> Request

-- | Set basic auth with the given username and password
setRequestBasicAuth :: ByteString -> ByteString -> Request -> Request

-- | Set bearer auth with the given token
setRequestBearerAuth :: ByteString -> Request -> Request

-- | Instead of using the default global Manager, use the supplied
--   Manager.
setRequestManager :: Manager -> Request -> Request

-- | Override the default proxy server settings
setRequestProxy :: Maybe Proxy -> Request -> Request

-- | Set the maximum time to wait for a response
setRequestResponseTimeout :: ResponseTimeout -> Request -> Request

-- | Get the status of the response
getResponseStatus :: Response a -> Status

-- | Get the integral status code of the response
getResponseStatusCode :: Response a -> Int

-- | Get all response header values with the given name
getResponseHeader :: HeaderName -> Response a -> [ByteString]

-- | Get all response headers
getResponseHeaders :: Response a -> [(HeaderName, ByteString)]

-- | Get the response body
getResponseBody :: Response a -> a

-- | Alternate spelling of httpLBS
httpLbs :: MonadIO m => Request -> m (Response ByteString)
instance GHC.Internal.Exception.Type.Exception Network.HTTP.Simple.JSONException
instance GHC.Internal.Show.Show Network.HTTP.Simple.JSONException
