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


-- | An HTTP client engine, intended as a base layer for more user-friendly packages.
--   
--   This codebase has been refactored from http-conduit.
@package http-client
@version 0.2.0.1


-- | Note that this is essentially the "kitchen sink" export module,
--   including many functions intended only to be used internally by this
--   package. No API stability is guaranteed for this module. If you see
--   functions here which you believe should be promoted to a stable API,
--   please contact the author.
module Network.HTTP.Client.Internal
makeChunkedReader :: Bool -> Connection -> IO BodyReader
makeLengthReader :: Int -> Connection -> IO BodyReader
makeGzipReader :: BodyReader -> IO BodyReader
makeUnlimitedReader :: Connection -> IO BodyReader

-- | Strictly consume all remaining chunks of data from the stream.
--   
--   Since 0.1.0
brConsume :: BodyReader -> IO [ByteString]
brEmpty :: BodyReader
brAddCleanup :: IO () -> BodyReader -> BodyReader
brReadSome :: BodyReader -> Int -> IO ByteString
connectionReadLine :: Connection -> IO ByteString
connectionReadLineWith :: Connection -> ByteString -> IO ByteString

-- | For testing
dummyConnection :: [ByteString] -> IO (Connection, IO [ByteString], IO [ByteString])
openSocketConnection :: Maybe HostAddress -> String -> Int -> IO Connection
makeConnection :: IO ByteString -> (ByteString -> IO ()) -> IO () -> IO Connection

-- | This applies <a>receiveSetCookie</a> 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 <a>generateCookie</a>
--   followed by <a>insertCheckedCookie</a>. Use this function if you plan
--   to do both in a row. <a>generateCookie</a> and
--   <a>insertCheckedCookie</a> are only provided for more fine-grained
--   control.
receiveSetCookie :: SetCookie -> Request -> UTCTime -> Bool -> CookieJar -> CookieJar

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

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

-- | This applies the <a>computeCookieString</a> 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 corresponds to the eviction algorithm described in Section 5.3
--   "Storage Model"
evictExpiredCookies :: CookieJar -> UTCTime -> CookieJar
createCookieJar :: [Cookie] -> CookieJar
destroyCookieJar :: CookieJar -> [Cookie]

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

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

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

-- | Perform a <tt>Request</tt> using a connection acquired from the given
--   <tt>Manager</tt>, and then provide the <tt>Response</tt> to the given
--   function. This function is fully exception safe, guaranteeing that the
--   response will be closed when the inner function exits. It is defined
--   as:
--   
--   <pre>
--   withResponse req man f = bracket (responseOpen req man) responseClose f
--   </pre>
--   
--   It is recommended that you use this function in place of explicit
--   calls to <a>responseOpen</a> and <a>responseClose</a>.
--   
--   You will need to use functions such as <a>brRead</a> to consume the
--   response body.
--   
--   Since 0.1.0
withResponse :: Request -> Manager -> (Response BodyReader -> IO a) -> IO a

-- | A convenience wrapper around <a>withResponse</a> which reads in the
--   entire response body and immediately closes the connection. Note that
--   this function performs fully strict I/O, and only uses a lazy
--   ByteString in its response for memory efficiency. If you are
--   anticipating a large response body, you are encouraged to use
--   <a>withResponse</a> and <a>brRead</a> instead.
--   
--   Since 0.1.0
httpLbs :: Request -> Manager -> IO (Response ByteString)

-- | Get a <a>Response</a> without any redirect following.
httpRaw :: Request -> Manager -> IO (Response BodyReader)

-- | The most low-level function for initiating an HTTP request.
--   
--   The first argument to this function gives a full specification on the
--   request: the host to connect to, whether to use SSL, headers, etc.
--   Please see <a>Request</a> for full details. The second argument
--   specifies which <a>Manager</a> should be used.
--   
--   This function then returns a <a>Response</a> with a <a>BodyReader</a>.
--   The <a>Response</a> contains the status code and headers that were
--   sent back to us, and the <a>BodyReader</a> contains the body of the
--   request. Note that this <a>BodyReader</a> allows you to have fully
--   interleaved IO actions during your HTTP download, making it possible
--   to download very large responses in constant memory.
--   
--   An important note: the response body returned by this function
--   represents a live HTTP connection. As such, if you do not use the
--   response body, an open socket will be retained indefinitely. You must
--   be certain to call <a>responseClose</a> on this response to free up
--   resources.
--   
--   This function automatically performs any necessary redirects, as
--   specified by the <a>redirectCount</a> setting.
--   
--   Since 0.1.0
responseOpen :: Request -> Manager -> IO (Response BodyReader)

-- | Close any open resources associated with the given <tt>Response</tt>.
--   In general, this will either close an active <tt>Connection</tt> or
--   return it to the <tt>Manager</tt> to be reused.
--   
--   Since 0.1.0
responseClose :: Response a -> IO ()

-- | Apply 'Request'\'s <a>checkStatus</a> and return resulting exception
--   if any.
applyCheckStatus :: (Status -> ResponseHeaders -> CookieJar -> Maybe SomeException) -> Response BodyReader -> IO (Maybe SomeException)

-- | Redirect loop
httpRedirect :: Int -> (Request -> IO (Response BodyReader, Maybe Request)) -> Request -> IO (Response BodyReader)
parseStatusHeaders :: Connection -> IO StatusHeaders

-- | Convert a URL into a <a>Request</a>.
--   
--   This defaults some of the values in <a>Request</a>, such as setting
--   <a>method</a> to GET and <a>requestHeaders</a> to <tt>[]</tt>.
--   
--   Since this function uses <a>Failure</a>, the return monad can be
--   anything that is an instance of <a>Failure</a>, such as <a>IO</a> or
--   <a>Maybe</a>.
--   
--   Since 0.1.0
parseUrl :: Failure HttpException m => String -> m Request

-- | Add a <a>URI</a> to the request. If it is absolute (includes a host
--   name), add it as per <a>setUri</a>; if it is relative, merge it with
--   the existing request.
setUriRelative :: Failure HttpException m => Request -> URI -> m Request

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

-- | Validate a <a>URI</a>, then add it to the request.
setUri :: Failure HttpException m => Request -> URI -> m Request

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

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

-- | 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

-- | Add a Basic Auth header (with the specified user name and password) to
--   the given Request. Ignore error handling:
--   
--   <pre>
--   applyBasicAuth "user" "pass" $ fromJust $ parseUrl url
--   </pre>
--   
--   Since 0.1.0
applyBasicAuth :: ByteString -> ByteString -> Request -> Request

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

-- | Magic value to be placed in a <a>Request</a> to indicate that we
--   should use the timeout value in the <tt>Manager</tt>.
--   
--   Since 1.9.3
useDefaultTimeout :: Maybe Int

-- | 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 <a>Nothing</a> if the code is not a 3xx, there is no
--   <tt>location</tt> header included, or if the redirected response
--   couldn't be parsed with <a>parseUrl</a>.
--   
--   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:
--   
--   <pre>
--   myHttp req man = do
--      (res, redirectRequests) &lt;- (`runStateT` []) $
--           'httpRedirect'
--               9000
--               (\req' -&gt; do
--                  res &lt;- http req'{redirectCount=0} man
--                  modify (\rqs -&gt; req' : rqs)
--                  return (res, getRedirectedRequest req' (responseHeaders res) (responseCookieJar res) (W.statusCode (responseStatus res))
--                  )
--               'lift'
--               req
--      applyCheckStatus (checkStatus req) res
--      return redirectRequests
--   </pre>
getRedirectedRequest :: Request -> ResponseHeaders -> CookieJar -> Int -> Maybe Request
getResponse :: ConnRelease -> Maybe Int -> Request -> Connection -> IO (Response BodyReader)

-- | Convert a <a>Response</a> that has a <tt>Source</tt> body to one with
--   a lazy <a>ByteString</a> body.
lbsResponse :: Response BodyReader -> IO (Response ByteString)

-- | Settings for a <tt>Manager</tt>. Please use the
--   <tt>defaultManagerSettings</tt> function and then modify individual
--   settings. For more information, see
--   <a>http://www.yesodweb.com/book/settings-types</a>.
--   
--   Since 0.1.0
data ManagerSettings
ManagerSettings :: !Int -> !(IO (Maybe HostAddress -> String -> Int -> IO Connection)) -> !(IO (Maybe HostAddress -> String -> Int -> IO Connection)) -> !(Maybe Int) -> !(SomeException -> Bool) -> !(forall a. IO a -> IO a) -> ManagerSettings

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

-- | Create an insecure connection.
--   
--   Since 0.1.0
managerRawConnection :: ManagerSettings -> !(IO (Maybe HostAddress -> String -> Int -> IO Connection))

-- | 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))

-- | Default timeout (in microseconds) to be applied to requests which do
--   not provide a timeout value.
--   
--   Default is 5 seconds
--   
--   Since 0.1.0
managerResponseTimeout :: ManagerSettings -> !(Maybe Int)

-- | Exceptions for which we should retry our request if we were reusing an
--   already open connection. In the case of IOExceptions, for example, we
--   assume that the connection was closed on the server and therefore open
--   a new one.
--   
--   Since 0.1.0
managerRetryableException :: ManagerSettings -> !(SomeException -> Bool)

-- | Action wrapped around all attempted <tt>Request</tt>s, usually used to
--   wrap up exceptions in library-specific types.
--   
--   Default: wrap all <tt>IOException</tt>s in the
--   <tt>InternalIOException</tt> constructor.
--   
--   Since 0.1.0
managerWrapIOException :: ManagerSettings -> !(forall a. IO a -> IO a)

-- | Create a <a>Manager</a>. You may manually call <a>closeManager</a> to
--   shut it down, or allow the <tt>Manager</tt> to be shut down
--   automatically based on garbage collection.
--   
--   Creating a new <a>Manager</a> is a relatively expensive operation, you
--   are advised to share a single <a>Manager</a> between requests instead.
--   
--   The first argument to this function is often
--   <a>defaultManagerSettings</a>, though add-on libraries may provide a
--   recommended replacement.
--   
--   Since 0.1.0
newManager :: ManagerSettings -> IO Manager

-- | Close all connections in a <a>Manager</a>.
--   
--   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 ()
getConn :: Request -> Manager -> IO (ConnRelease, Connection, ManagedConn)

-- | Create an exception to be thrown if the connection for the given
--   request fails.
failedConnectionException :: Request -> HttpException

-- | Default value for <tt>ManagerSettings</tt>.
--   
--   Since 0.1.0
defaultManagerSettings :: ManagerSettings

-- | An abstraction for representing an incoming response body coming from
--   the server. Data provided by this abstraction has already been
--   gunzipped and de-chunked, and respects any content-length headers
--   present.
--   
--   Since 0.1.0
data BodyReader
BodyReader :: !(IO ByteString) -> !(IO Bool) -> BodyReader

-- | Get a single chunk of data from the response body, or an empty
--   bytestring if no more data is available.
--   
--   Since 0.1.0
brRead :: BodyReader -> !(IO ByteString)
brComplete :: BodyReader -> !(IO Bool)
data Connection
Connection :: !(IO ByteString) -> !(ByteString -> IO ()) -> !(ByteString -> IO ()) -> !(IO ()) -> Connection

-- | If no more data, return empty.
connectionRead :: Connection -> !(IO ByteString)

-- | Return data to be read next time.
connectionUnread :: Connection -> !(ByteString -> IO ())

-- | Send data to server
connectionWrite :: Connection -> !(ByteString -> IO ())
connectionClose :: Connection -> !(IO ())
data StatusHeaders
StatusHeaders :: !Status -> !HttpVersion -> !RequestHeaders -> StatusHeaders
data HttpException
StatusCodeException :: Status -> ResponseHeaders -> CookieJar -> HttpException
InvalidUrlException :: String -> String -> HttpException

-- | List of encountered responses containing redirects in reverse
--   chronological order; including last redirect, which triggered the
--   exception and was not followed.
TooManyRedirects :: [Response ByteString] -> HttpException

-- | Response containing unparseable redirect.
UnparseableRedirect :: (Response ByteString) -> HttpException
TooManyRetries :: HttpException
HttpParserException :: String -> HttpException
HandshakeFailed :: HttpException
OverlongHeaders :: HttpException
ResponseTimeout :: HttpException

-- | host/port
FailedConnectionException :: String -> Int -> HttpException
ExpectedBlankAfter100Continue :: HttpException
InvalidStatusLine :: ByteString -> HttpException
InvalidHeader :: ByteString -> HttpException
InternalIOException :: IOException -> HttpException

-- | host/port
ProxyConnectException :: ByteString -> Int -> (Either ByteString HttpException) -> HttpException
NoResponseDataReceived :: HttpException
TlsException :: SomeException -> HttpException
TlsNotSupported :: HttpException

-- | Expected size/actual size.
--   
--   Since 1.9.4
ResponseBodyTooShort :: Word64 -> Word64 -> HttpException

-- | Since 1.9.4
InvalidChunkHeaders :: HttpException
IncompleteHeaders :: HttpException
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
newtype CookieJar
CJ :: [Cookie] -> CookieJar
expose :: CookieJar -> [Cookie]

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

-- | The host name of the HTTP proxy.
proxyHost :: Proxy -> !ByteString

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

-- | When using one of the <a>RequestBodyStream</a> /
--   <a>RequestBodyStreamChunked</a> constructors, you must ensure that the
--   <a>GivesPopper</a> can be called multiple times. Usually this is not a
--   problem.
--   
--   The <a>RequestBodyStreamChunked</a> will send a chunked request body.
--   Note that not all servers support this. Only use
--   <a>RequestBodyStreamChunked</a> 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

-- | 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

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

-- | A function which will provide a <a>Popper</a> to a <a>NeedsPopper</a>.
--   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

-- | 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 <tt>parseUrl</tt>.
--   
--   The constructor for this data type is not exposed. Instead, you should
--   use either the <a>def</a> method to retrieve a default instance, or
--   <tt>parseUrl</tt> 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:
--   
--   <pre>
--   initReq &lt;- parseUrl "http://www.example.com/path"
--   let req = initReq
--               { method = "POST"
--               }
--   </pre>
--   
--   For more information, please see
--   <a>http://www.yesodweb.com/book/settings-types</a>.
--   
--   Since 0.1.0
data Request
Request :: Method -> Bool -> ByteString -> Int -> ByteString -> ByteString -> RequestHeaders -> RequestBody -> Maybe Proxy -> Maybe HostAddress -> Bool -> (ByteString -> Bool) -> Int -> (Status -> ResponseHeaders -> CookieJar -> Maybe SomeException) -> Maybe Int -> (Maybe Int -> HttpException -> IO (ConnRelease, Connection, ManagedConn) -> IO (Maybe Int, (ConnRelease, Connection, ManagedConn))) -> Maybe CookieJar -> 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 <tt>host</tt> request header.
--   
--   Since 0.1.0
host :: Request -> ByteString

-- | The port to connect to. Also used for generating the <tt>host</tt>
--   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 <tt>requestHeaders</tt>.
--   
--   If not provided by the user, <tt>Host</tt> will automatically be set
--   based on the <tt>host</tt> and <tt>port</tt> 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 <a>decompress</a>
--   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 <tt>True</tt>, 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 <tt>alwaysDecompress</tt> and
--   <tt>browserDecompress</tt>). 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

-- | Check the status code. Note that this will run after all redirects are
--   performed. Default: return a <tt>StatusCodeException</tt> on non-2XX
--   responses.
--   
--   Since 0.1.0
checkStatus :: Request -> Status -> ResponseHeaders -> CookieJar -> Maybe SomeException

-- | Number of microseconds to wait for a response. If <tt>Nothing</tt>,
--   will wait indefinitely. Default: 5 seconds.
--   
--   Since 0.1.0
responseTimeout :: Request -> Maybe Int

-- | Wraps the calls for getting new connections. This can be useful for
--   instituting some kind of timeouts. The first argument is the value of
--   <tt>responseTimeout</tt>. Second argument is the exception to be
--   thrown on failure.
--   
--   Default: If <tt>responseTimeout</tt> is <tt>Nothing</tt>, does
--   nothing. Otherwise, institutes timeout, and returns remaining time for
--   <tt>responseTimeout</tt>.
--   
--   Since 0.1.0
getConnectionWrapper :: Request -> Maybe Int -> HttpException -> IO (ConnRelease, Connection, ManagedConn) -> IO (Maybe Int, (ConnRelease, Connection, ManagedConn))

-- | A user-defined cookie jar. If <a>Nothing</a>, no cookie handling will
--   take place, "Cookie" headers in <a>requestHeaders</a> will be sent
--   raw, and <a>responseCookieJar</a> will be empty.
--   
--   Since 0.1.0
cookieJar :: Request -> Maybe CookieJar
data ConnReuse
Reuse :: ConnReuse
DontReuse :: ConnReuse
type ConnRelease = ConnReuse -> IO ()
data ManagedConn
Fresh :: ManagedConn
Reused :: ManagedConn

-- | A simple representation of the HTTP response.
--   
--   Since 0.1.0
data Response body
Response :: !Status -> !HttpVersion -> !ResponseHeaders -> !body -> !CookieJar -> !ResponseClose -> 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 <a>cookieJar</a> to
--   <tt>Nothing</tt>, then this will always be empty.
--   
--   Since 0.1.0
responseCookieJar :: Response body -> !CookieJar

-- | Releases any resource held by this response. If the response body has
--   not been fully read yet, doing so after this call will likely be
--   impossible.
--   
--   Since 0.1.0
responseClose' :: Response body -> !ResponseClose
newtype ResponseClose
ResponseClose :: IO () -> ResponseClose
runResponseClose :: ResponseClose -> IO ()

-- | Keeps track of open connections for keep-alive.
--   
--   If possible, you should share a single <a>Manager</a> between multiple
--   threads and requests.
--   
--   Since 0.1.0
data Manager
Manager :: !(IORef (Maybe (Map ConnKey (NonEmptyList Connection)))) -> !Int -> !(Maybe Int) -> !(Maybe HostAddress -> String -> Int -> IO Connection) -> !(Maybe HostAddress -> String -> Int -> IO Connection) -> !(SomeException -> Bool) -> !(forall a. IO a -> IO a) -> Manager

-- | <tt>Nothing</tt> indicates that the manager is closed.
mConns :: Manager -> !(IORef (Maybe (Map ConnKey (NonEmptyList Connection))))

-- | This is a per-<tt>ConnKey</tt> value.
mMaxConns :: Manager -> !Int

-- | Copied from <a>managerResponseTimeout</a>
mResponseTimeout :: Manager -> !(Maybe Int)
mRawConnection :: Manager -> !(Maybe HostAddress -> String -> Int -> IO Connection)
mTlsConnection :: Manager -> !(Maybe HostAddress -> String -> Int -> IO Connection)
mRetryableException :: Manager -> !(SomeException -> Bool)
mWrapIOException :: Manager -> !(forall a. IO a -> IO a)

-- | Settings for a <tt>Manager</tt>. Please use the
--   <tt>defaultManagerSettings</tt> function and then modify individual
--   settings. For more information, see
--   <a>http://www.yesodweb.com/book/settings-types</a>.
--   
--   Since 0.1.0
data ManagerSettings
ManagerSettings :: !Int -> !(IO (Maybe HostAddress -> String -> Int -> IO Connection)) -> !(IO (Maybe HostAddress -> String -> Int -> IO Connection)) -> !(Maybe Int) -> !(SomeException -> Bool) -> !(forall a. IO a -> IO a) -> ManagerSettings

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

-- | Create an insecure connection.
--   
--   Since 0.1.0
managerRawConnection :: ManagerSettings -> !(IO (Maybe HostAddress -> String -> Int -> IO Connection))

-- | 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))

-- | Default timeout (in microseconds) to be applied to requests which do
--   not provide a timeout value.
--   
--   Default is 5 seconds
--   
--   Since 0.1.0
managerResponseTimeout :: ManagerSettings -> !(Maybe Int)

-- | Exceptions for which we should retry our request if we were reusing an
--   already open connection. In the case of IOExceptions, for example, we
--   assume that the connection was closed on the server and therefore open
--   a new one.
--   
--   Since 0.1.0
managerRetryableException :: ManagerSettings -> !(SomeException -> Bool)

-- | Action wrapped around all attempted <tt>Request</tt>s, usually used to
--   wrap up exceptions in library-specific types.
--   
--   Default: wrap all <tt>IOException</tt>s in the
--   <tt>InternalIOException</tt> constructor.
--   
--   Since 0.1.0
managerWrapIOException :: ManagerSettings -> !(forall a. IO a -> IO a)
data NonEmptyList a
One :: !a -> !UTCTime -> NonEmptyList a
Cons :: !a -> !Int -> !UTCTime -> !(NonEmptyList a) -> NonEmptyList a

-- | Hostname or resolved host address.
data ConnHost
HostName :: !Text -> ConnHost
HostAddress :: !HostAddress -> ConnHost

-- | <tt>ConnKey</tt> consists of a hostname, a port and a <tt>Bool</tt>
--   specifying whether to use SSL.
data ConnKey
ConnKey :: !ConnHost -> !Int -> !Bool -> ConnKey

-- | Like <a>hGet</a>, except that a shorter <a>ByteString</a> may be
--   returned if there are not enough bytes immediately available to
--   satisfy the whole request. <a>hGetSome</a> only blocks if there is no
--   data available, and EOF has not yet been reached.
hGetSome :: Handle -> Int -> IO ByteString
(<>) :: Monoid m => m -> m -> m
readDec :: Integral i => String -> Maybe i
hasNoBody :: ByteString -> Int -> Bool

-- | <i>O(1)</i> Convert a strict <a>ByteString</a> into a lazy
--   <a>ByteString</a>.
fromStrict :: ByteString -> ByteString


-- | This is the main entry point for using http-client. Used by itself,
--   this module provides low-level access for streaming request and
--   response bodies, and only non-secure HTTP connections. Helper packages
--   such as http-conduit provided higher level streaming approaches, while
--   other helper packages like http-client-tls provide secure connections.
--   
--   There are three core components to be understood here: requests,
--   responses, and managers. A <tt>Manager</tt> keeps track of open
--   connections to various hosts, and when requested, will provide either
--   an existing open connection or create a new connection on demand. A
--   <tt>Manager</tt> also automatically reaps connections which have been
--   unused for a certain period of time. A <tt>Manager</tt> allows for
--   more efficient HTTP usage by allowing for keep-alive connections.
--   Secure HTTP connections can be allowed by modifying the settings used
--   for creating a manager. The simplest way to create a <tt>Manager</tt>
--   is with:
--   
--   <pre>
--   'newManager' 'defaultManagerSettings'
--   </pre>
--   
--   The next core component is a <tt>Request</tt>, which represents a
--   single HTTP request to be sent to a specific server. <tt>Request</tt>s
--   allow for many settings to control exact how they function, but
--   usually the simplest approach for creating a <tt>Request</tt> is to
--   use <a>parseUrl</a>.
--   
--   Finally, a <tt>Response</tt> is the result of sending a single
--   <tt>Request</tt> to a server, over a connection which was acquired
--   from a <tt>Manager</tt>. Note that you must close the response when
--   you're done with it to ensure that the connection is recycled to the
--   <tt>Manager</tt> to either be used by another request, or to be
--   reaped. Usage of <tt>withResponse</tt> will ensure that this happens
--   automatically.
--   
--   Helper packages may provide replacements for various recommendations
--   listed above. For example, if using http-client-tls, instead of using
--   <a>defaultManagerSettings</a>, you would want to use
--   <tt>tlsManagerSettings</tt>. Be sure to read the relevant helper
--   library documentation for more information.
--   
--   A note on exceptions: for the most part, all actions that perform I/O
--   should be assumed to throw an <tt>HttpException</tt> in the event of
--   some problem, and all pure functions will be total. For example,
--   <tt>withResponse</tt>, <tt>httpLbs</tt>, and <tt>brRead</tt> can all
--   throw exceptions. Functions like <tt>responseStatus</tt> and
--   <tt>applyBasicAuth</tt> are guaranteed to be total (or there's a bug
--   in the library).
--   
--   One thing to be cautioned about: the type of <tt>parseUrl</tt> allows
--   it to work in different monads. If used in the <tt>IO</tt> monad, it
--   will throw an exception in the case of an invalid URI. In addition, if
--   you leverage the <tt>IsString</tt> instance of the <tt>Request</tt>
--   value via <tt>OverloadedStrings</tt>, an invalid URI will result in a
--   partial value. Caveat emptor!
module Network.HTTP.Client

-- | Perform a <tt>Request</tt> using a connection acquired from the given
--   <tt>Manager</tt>, and then provide the <tt>Response</tt> to the given
--   function. This function is fully exception safe, guaranteeing that the
--   response will be closed when the inner function exits. It is defined
--   as:
--   
--   <pre>
--   withResponse req man f = bracket (responseOpen req man) responseClose f
--   </pre>
--   
--   It is recommended that you use this function in place of explicit
--   calls to <a>responseOpen</a> and <a>responseClose</a>.
--   
--   You will need to use functions such as <a>brRead</a> to consume the
--   response body.
--   
--   Since 0.1.0
withResponse :: Request -> Manager -> (Response BodyReader -> IO a) -> IO a

-- | A convenience wrapper around <a>withResponse</a> which reads in the
--   entire response body and immediately closes the connection. Note that
--   this function performs fully strict I/O, and only uses a lazy
--   ByteString in its response for memory efficiency. If you are
--   anticipating a large response body, you are encouraged to use
--   <a>withResponse</a> and <a>brRead</a> instead.
--   
--   Since 0.1.0
httpLbs :: Request -> Manager -> IO (Response ByteString)

-- | The most low-level function for initiating an HTTP request.
--   
--   The first argument to this function gives a full specification on the
--   request: the host to connect to, whether to use SSL, headers, etc.
--   Please see <a>Request</a> for full details. The second argument
--   specifies which <a>Manager</a> should be used.
--   
--   This function then returns a <a>Response</a> with a <a>BodyReader</a>.
--   The <a>Response</a> contains the status code and headers that were
--   sent back to us, and the <a>BodyReader</a> contains the body of the
--   request. Note that this <a>BodyReader</a> allows you to have fully
--   interleaved IO actions during your HTTP download, making it possible
--   to download very large responses in constant memory.
--   
--   An important note: the response body returned by this function
--   represents a live HTTP connection. As such, if you do not use the
--   response body, an open socket will be retained indefinitely. You must
--   be certain to call <a>responseClose</a> on this response to free up
--   resources.
--   
--   This function automatically performs any necessary redirects, as
--   specified by the <a>redirectCount</a> setting.
--   
--   Since 0.1.0
responseOpen :: Request -> Manager -> IO (Response BodyReader)

-- | Close any open resources associated with the given <tt>Response</tt>.
--   In general, this will either close an active <tt>Connection</tt> or
--   return it to the <tt>Manager</tt> to be reused.
--   
--   Since 0.1.0
responseClose :: Response a -> IO ()

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

-- | Create a <a>Manager</a>. You may manually call <a>closeManager</a> to
--   shut it down, or allow the <tt>Manager</tt> to be shut down
--   automatically based on garbage collection.
--   
--   Creating a new <a>Manager</a> is a relatively expensive operation, you
--   are advised to share a single <a>Manager</a> between requests instead.
--   
--   The first argument to this function is often
--   <a>defaultManagerSettings</a>, though add-on libraries may provide a
--   recommended replacement.
--   
--   Since 0.1.0
newManager :: ManagerSettings -> IO Manager

-- | Close all connections in a <a>Manager</a>.
--   
--   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 <tt>Manager</tt>. Please use the
--   <tt>defaultManagerSettings</tt> function and then modify individual
--   settings. For more information, see
--   <a>http://www.yesodweb.com/book/settings-types</a>.
--   
--   Since 0.1.0
data ManagerSettings

-- | Default value for <tt>ManagerSettings</tt>.
--   
--   Since 0.1.0
defaultManagerSettings :: ManagerSettings

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

-- | Create an insecure connection.
--   
--   Since 0.1.0
managerRawConnection :: ManagerSettings -> (IO (Maybe HostAddress -> String -> Int -> IO Connection))

-- | 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))

-- | Default timeout (in microseconds) to be applied to requests which do
--   not provide a timeout value.
--   
--   Default is 5 seconds
--   
--   Since 0.1.0
managerResponseTimeout :: ManagerSettings -> (Maybe Int)

-- | Exceptions for which we should retry our request if we were reusing an
--   already open connection. In the case of IOExceptions, for example, we
--   assume that the connection was closed on the server and therefore open
--   a new one.
--   
--   Since 0.1.0
managerRetryableException :: ManagerSettings -> (SomeException -> Bool)

-- | Action wrapped around all attempted <tt>Request</tt>s, usually used to
--   wrap up exceptions in library-specific types.
--   
--   Default: wrap all <tt>IOException</tt>s in the
--   <tt>InternalIOException</tt> constructor.
--   
--   Since 0.1.0
managerWrapIOException :: ManagerSettings -> (forall a. IO a -> IO a)

-- | Convert a URL into a <a>Request</a>.
--   
--   This defaults some of the values in <a>Request</a>, such as setting
--   <a>method</a> to GET and <a>requestHeaders</a> to <tt>[]</tt>.
--   
--   Since this function uses <a>Failure</a>, the return monad can be
--   anything that is an instance of <a>Failure</a>, such as <a>IO</a> or
--   <a>Maybe</a>.
--   
--   Since 0.1.0
parseUrl :: Failure HttpException m => String -> m Request

-- | Add a Basic Auth header (with the specified user name and password) to
--   the given Request. Ignore error handling:
--   
--   <pre>
--   applyBasicAuth "user" "pass" $ fromJust $ parseUrl url
--   </pre>
--   
--   Since 0.1.0
applyBasicAuth :: ByteString -> ByteString -> Request -> Request

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

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

-- | 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 <tt>parseUrl</tt>.
--   
--   The constructor for this data type is not exposed. Instead, you should
--   use either the <a>def</a> method to retrieve a default instance, or
--   <tt>parseUrl</tt> 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:
--   
--   <pre>
--   initReq &lt;- parseUrl "http://www.example.com/path"
--   let req = initReq
--               { method = "POST"
--               }
--   </pre>
--   
--   For more information, please see
--   <a>http://www.yesodweb.com/book/settings-types</a>.
--   
--   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 <tt>host</tt> request header.
--   
--   Since 0.1.0
host :: Request -> ByteString

-- | The port to connect to. Also used for generating the <tt>host</tt>
--   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 <tt>requestHeaders</tt>.
--   
--   If not provided by the user, <tt>Host</tt> will automatically be set
--   based on the <tt>host</tt> and <tt>port</tt> 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 <a>decompress</a>
--   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

-- | Predicate to specify whether gzipped data should be decompressed on
--   the fly (see <tt>alwaysDecompress</tt> and
--   <tt>browserDecompress</tt>). 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

-- | Check the status code. Note that this will run after all redirects are
--   performed. Default: return a <tt>StatusCodeException</tt> on non-2XX
--   responses.
--   
--   Since 0.1.0
checkStatus :: Request -> Status -> ResponseHeaders -> CookieJar -> Maybe SomeException

-- | Number of microseconds to wait for a response. If <tt>Nothing</tt>,
--   will wait indefinitely. Default: 5 seconds.
--   
--   Since 0.1.0
responseTimeout :: Request -> Maybe Int

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

-- | When using one of the <a>RequestBodyStream</a> /
--   <a>RequestBodyStreamChunked</a> constructors, you must ensure that the
--   <a>GivesPopper</a> can be called multiple times. Usually this is not a
--   problem.
--   
--   The <a>RequestBodyStreamChunked</a> will send a chunked request body.
--   Note that not all servers support this. Only use
--   <a>RequestBodyStreamChunked</a> 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

-- | 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

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

-- | A function which will provide a <a>Popper</a> to a <a>NeedsPopper</a>.
--   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 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 <a>cookieJar</a> to
--   <tt>Nothing</tt>, then this will always be empty.
--   
--   Since 0.1.0
responseCookieJar :: Response body -> CookieJar

-- | An abstraction for representing an incoming response body coming from
--   the server. Data provided by this abstraction has already been
--   gunzipped and de-chunked, and respects any content-length headers
--   present.
--   
--   Since 0.1.0
data BodyReader

-- | Get a single chunk of data from the response body, or an empty
--   bytestring if no more data is available.
--   
--   Since 0.1.0
brRead :: BodyReader -> (IO ByteString)

-- | Strictly consume all remaining chunks of data from the stream.
--   
--   Since 0.1.0
brConsume :: BodyReader -> IO [ByteString]
data HttpException
StatusCodeException :: Status -> ResponseHeaders -> CookieJar -> HttpException
InvalidUrlException :: String -> String -> HttpException

-- | List of encountered responses containing redirects in reverse
--   chronological order; including last redirect, which triggered the
--   exception and was not followed.
TooManyRedirects :: [Response ByteString] -> HttpException

-- | Response containing unparseable redirect.
UnparseableRedirect :: (Response ByteString) -> HttpException
TooManyRetries :: HttpException
HttpParserException :: String -> HttpException
HandshakeFailed :: HttpException
OverlongHeaders :: HttpException
ResponseTimeout :: HttpException

-- | host/port
FailedConnectionException :: String -> Int -> HttpException
ExpectedBlankAfter100Continue :: HttpException
InvalidStatusLine :: ByteString -> HttpException
InvalidHeader :: ByteString -> HttpException
InternalIOException :: IOException -> HttpException

-- | host/port
ProxyConnectException :: ByteString -> Int -> (Either ByteString HttpException) -> HttpException
NoResponseDataReceived :: HttpException
TlsException :: SomeException -> HttpException
TlsNotSupported :: HttpException

-- | Expected size/actual size.
--   
--   Since 1.9.4
ResponseBodyTooShort :: Word64 -> Word64 -> HttpException

-- | Since 1.9.4
InvalidChunkHeaders :: HttpException
IncompleteHeaders :: HttpException
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

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

-- | The host name of the HTTP proxy.
proxyHost :: Proxy -> !ByteString

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

-- | This applies <a>receiveSetCookie</a> 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 <a>generateCookie</a>
--   followed by <a>insertCheckedCookie</a>. Use this function if you plan
--   to do both in a row. <a>generateCookie</a> and
--   <a>insertCheckedCookie</a> are only provided for more fine-grained
--   control.
receiveSetCookie :: SetCookie -> Request -> UTCTime -> Bool -> CookieJar -> CookieJar

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

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

-- | This applies the <a>computeCookieString</a> 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 corresponds to the eviction algorithm described in Section 5.3
--   "Storage Model"
evictExpiredCookies :: CookieJar -> UTCTime -> CookieJar
createCookieJar :: [Cookie] -> CookieJar
destroyCookieJar :: CookieJar -> [Cookie]

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

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

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