Abstraction over HTTP clients
This avoids insisting on a particular implementation (such as the HTTP package) and allows for other implementations (such as a conduit based one).
NOTE: Library-specific exceptions MUST be wrapped in SomeRemoteError.
Constructors
HttpLibhttpGet :: forall a. Throws SomeRemoteError => [HttpRequestHeader] -> URI -> ([HttpResponseHeader] -> BodyReader -> IO a) -> IO aDownload a file
httpGetRange :: forall a. Throws SomeRemoteError => [HttpRequestHeader] -> URI -> (Int, Int) -> (HttpStatus -> [HttpResponseHeader] -> BodyReader -> IO a) -> IO aDownload a byte range
Range is starting and (exclusive) end offset in bytes.
HTTP servers are normally expected to respond to a range request with a "206 Partial Content" response. However, servers can respond with a "200 OK" response, sending the entire file instead (for instance, this may happen for servers that don't actually support range requests, but for which we optimistically assumed they did). Implementations of HttpLib may accept such a response and inform the
hackage-securitylibrary that the whole file is being returned; the security library can then decide to execute the BodyReader anyway (downloading the entire file) or abort the request and try something else. For this reason the security library must be informed whether the server returned the full file or the requested range.