Safe Haskell | None |
---|---|
Language | Haskell2010 |
Abstracting over HTTP libraries
Synopsis
- data HttpLib = HttpLib {
- httpGet :: forall a. Throws SomeRemoteError => [HttpRequestHeader] -> URI -> ([HttpResponseHeader] -> BodyReader -> IO a) -> IO a
- httpGetRange :: forall a. Throws SomeRemoteError => [HttpRequestHeader] -> URI -> (Int, Int) -> (HttpStatus -> [HttpResponseHeader] -> BodyReader -> IO a) -> IO a
- data HttpRequestHeader
- data HttpResponseHeader = HttpResponseAcceptRangesBytes
- data HttpStatus
- data ProxyConfig a
- type BodyReader = IO ByteString
- bodyReaderFromBS :: ByteString -> IO BodyReader
Documentation
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
.
HttpLib | |
|
data HttpRequestHeader Source #
Additional request headers
Since different libraries represent headers differently, here we just abstract over the few request headers that we might want to set
HttpRequestMaxAge0 | Set |
HttpRequestNoTransform | Set |
Instances
Eq HttpRequestHeader Source # | |
Defined in Hackage.Security.Client.Repository.HttpLib (==) :: HttpRequestHeader -> HttpRequestHeader -> Bool # (/=) :: HttpRequestHeader -> HttpRequestHeader -> Bool # | |
Ord HttpRequestHeader Source # | |
Defined in Hackage.Security.Client.Repository.HttpLib compare :: HttpRequestHeader -> HttpRequestHeader -> Ordering # (<) :: HttpRequestHeader -> HttpRequestHeader -> Bool # (<=) :: HttpRequestHeader -> HttpRequestHeader -> Bool # (>) :: HttpRequestHeader -> HttpRequestHeader -> Bool # (>=) :: HttpRequestHeader -> HttpRequestHeader -> Bool # max :: HttpRequestHeader -> HttpRequestHeader -> HttpRequestHeader # min :: HttpRequestHeader -> HttpRequestHeader -> HttpRequestHeader # | |
Show HttpRequestHeader Source # | |
Defined in Hackage.Security.Client.Repository.HttpLib showsPrec :: Int -> HttpRequestHeader -> ShowS # show :: HttpRequestHeader -> String # showList :: [HttpRequestHeader] -> ShowS # |
data HttpResponseHeader Source #
Response headers
Since different libraries represent headers differently, here we just abstract over the few response headers that we might want to know about.
HttpResponseAcceptRangesBytes | Server accepts byte-range requests ( |
Instances
Eq HttpResponseHeader Source # | |
Defined in Hackage.Security.Client.Repository.HttpLib (==) :: HttpResponseHeader -> HttpResponseHeader -> Bool # (/=) :: HttpResponseHeader -> HttpResponseHeader -> Bool # | |
Ord HttpResponseHeader Source # | |
Defined in Hackage.Security.Client.Repository.HttpLib compare :: HttpResponseHeader -> HttpResponseHeader -> Ordering # (<) :: HttpResponseHeader -> HttpResponseHeader -> Bool # (<=) :: HttpResponseHeader -> HttpResponseHeader -> Bool # (>) :: HttpResponseHeader -> HttpResponseHeader -> Bool # (>=) :: HttpResponseHeader -> HttpResponseHeader -> Bool # max :: HttpResponseHeader -> HttpResponseHeader -> HttpResponseHeader # min :: HttpResponseHeader -> HttpResponseHeader -> HttpResponseHeader # | |
Show HttpResponseHeader Source # | |
Defined in Hackage.Security.Client.Repository.HttpLib showsPrec :: Int -> HttpResponseHeader -> ShowS # show :: HttpResponseHeader -> String # showList :: [HttpResponseHeader] -> ShowS # |
data HttpStatus Source #
HTTP status code
HttpStatus200OK | 200 OK |
HttpStatus206PartialContent | 206 Partial Content |
data ProxyConfig a Source #
Proxy configuration
Although actually setting the proxy is the purview of the initialization
function for individual HttpLib
implementations and therefore outside
the scope of this module, we offer this ProxyConfiguration
type here as a
way to uniformly configure proxies across all HttpLib
s.
ProxyConfigNone | Don't use a proxy |
ProxyConfigUse a | Use this specific proxy Individual HTTP backends use their own types for specifying proxies. |
ProxyConfigAuto | Use automatic proxy settings What precisely automatic means is |
Body reader
type BodyReader = IO ByteString Source #
An IO
action that represents an incoming response body coming from the
server.
The action gets a single chunk of data from the response body, or an empty bytestring if no more data is available.
This definition is copied from the http-client
package.
bodyReaderFromBS :: ByteString -> IO BodyReader Source #
Construct a Body
reader from a lazy bytestring
This is appropriate if the lazy bytestring is constructed, say, by calling
hGetContents
on a network socket, and the chunks of the bytestring
correspond to the chunks as they are returned from the OS network layer.
If the lazy bytestring needs to be re-chunked this function is NOT suitable.