| Safe Haskell | None |
|---|
Network.HTTP.Client.Response
- data Response body = Response {}
- getRedirectedRequest :: Request -> ResponseHeaders -> CookieJar -> Int -> Maybe Request
- getResponse :: ConnRelease -> Maybe Int -> Request -> Connection -> IO (Response BodyReader)
- lbsResponse :: Response BodyReader -> IO (Response ByteString)
Documentation
A simple representation of the HTTP response created by lbsConsumer.
Constructors
| Response | |
Fields
| |
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
getResponse :: ConnRelease -> Maybe Int -> Request -> Connection -> IO (Response BodyReader)Source
lbsResponse :: Response BodyReader -> IO (Response ByteString)Source
Convert a Response that has a Source body to one with a lazy
ByteString body.