http-client-0.1.0.0: An HTTP client engine, intended as a base layer for more user-friendly packages.

Safe HaskellNone

Network.HTTP.Client.Response

Synopsis

Documentation

data Response body Source

A simple representation of the HTTP response created by lbsConsumer.

Constructors

Response 

Fields

responseStatus :: !Status

Status code of the response.

responseVersion :: !HttpVersion

HTTP version used by the server.

responseHeaders :: !ResponseHeaders

Response headers sent by the server.

responseBody :: !body

Response body sent by the server.

responseCookieJar :: !CookieJar

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.

responseClose' :: !ResponseClose

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.

Instances

Functor Response 
Typeable1 Response 
Eq body => Eq (Response body) 
Show body => Show (Response body) 

getRedirectedRequest :: Request -> ResponseHeaders -> CookieJar -> Int -> Maybe RequestSource

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

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' (responseHeaders res) (responseCookieJar res) (W.statusCode (responseStatus res))
                )
             'lift'
             req
    applyCheckStatus (checkStatus req) res
    return redirectRequests

lbsResponse :: Response BodyReader -> IO (Response ByteString)Source

Convert a Response that has a Source body to one with a lazy ByteString body.