http-client-brread-timeout-0.1.0.1: Http client with time-limited brRead
Copyright(c) Alexey Radkov 2022
LicenseBSD-style
Maintaineralexey.radkov@gmail.com
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Network.HTTP.Client.BrReadWithTimeout

Description

Http client with timeouts applied in between body read events.

Note that the response timeout in http-client is applied only when receiving the response headers which is not always satisfactory given that a slow server may send the rest of the response very slowly.

Synopsis

Documentation

fromResponseTimeout :: Request -> Manager -> Int Source #

Converts ResponseTimeout of the request into the number of microseconds.

brReadWithTimeout :: Int -> Request -> BodyReader -> IO ByteString Source #

Reads the next chunk of the response body with the specified timeout.

Note that brRead and httpLbs do not apply any timeouts after reading response headers. This may hang the client if the server implementation is buggy, for instance, when it sends a body of a lesser size than the value of the Content-Length response header. This function solves this problem by applying a timeout passed in the first parameter as a number of microseconds between body read events.

Throws ResponseTimeout if reading of the next chunk of the response body timed out.

httpLbsBrReadWithTimeout :: Request -> Manager -> IO (Response ByteString) Source #

This is like httpLbs but with a timeout between body read events.

The value of the timeout is retrieved from the ResponseTimeout of the request.