Safe Haskell | Safe-Infered |
---|
- simpleHttp :: MonadIO m => HttpReq () -> L -> Maybe SSLContext -> m (HttpResp m)
- genSimpleHttp :: MonadIO m => HttpReq () -> L -> Maybe SSLContext -> Int -> Bool -> m (HttpResp m)
- headRequest :: String -> HttpReq ()
- getRequest :: String -> HttpReq ()
- postRequest :: String -> String -> L -> HttpReq ()
- simpleGetHttp :: MonadIO m => String -> m (HttpResp m)
- simpleGetHttps :: MonadIO m => String -> SSLContext -> m (HttpResp m)
- simpleHeadHttp :: MonadIO m => String -> m (HttpResp m)
- simpleHeadHttps :: MonadIO m => String -> SSLContext -> m (HttpResp m)
- data HttpClient = HttpClient {
- hcSock :: !Socket
- hcSockAddr :: !SockAddr
- hcSslCtx :: !(Maybe SSLContext)
- hcIsHttps :: !Bool
- mkHttpClient :: S -> Int -> Maybe SSLContext -> Bool -> IO HttpClient
- httpConnect :: MonadIO m => HttpClient -> IO (Iter L m (), Onum L m a)
- inumHttpClient :: MonadIO m => (HttpReq s, L) -> HttpResponseHandler m s -> Inum L L m a
- type HttpResponseHandler m s = HttpResp m -> Iter L m (Maybe (HttpReq s, L))
- userAgent :: String
- maxNrRedirects :: Int
- mkRequestToAbsUri :: Monad m => L -> S -> m (HttpReq ())
Simple interface
:: MonadIO m | |
=> HttpReq () | Request header |
-> L | Request body |
-> Maybe SSLContext | SSL Context |
-> m (HttpResp m) |
Perform a simple HTTP request, given the the request header, body and SSL context, if any.
:: MonadIO m | |
=> HttpReq () | Request header |
-> L | Message body |
-> Maybe SSLContext | SSL Context |
-> Int | Redirect count |
-> Bool | Pass cookies |
-> m (HttpResp m) |
Make a general HTTP request to host specified in the request.
If the request is over HTTPS, the SSL context must be provided.
The redirect count is used to limit the number of redirects
followed (when receiving a 3xx response); use 0 to return the
direct response. The passCookies
flag is used to guard cookies
on redirects: because genSimpleHttp
performs a "single request"
it does not parse "Set-Cookie" headers and so is unaware of the
cookie domain. Hence, the flag is used for the decision in passing
the cookie to the location of a redirect.
headRequest :: String -> HttpReq ()Source
Create a simple HEAD request.
The url
must be an absoluteURI
.
getRequest :: String -> HttpReq ()Source
Create a simple GET request.
The url
must be an absoluteURI
.
Given a URL, Content-Type, and message body, perform a simple POST request. Note: message body must be properly encoded (e.g., URL-encoded if the Content-Type is "application/x-www-form-urlencoded").
GET, HEAD wrappers
Perform a simple HTTP GET request. No SSL support.
:: MonadIO m | |
=> String | URL |
-> SSLContext | SSL Context |
-> m (HttpResp m) |
Perform a simple HTTPS GET request.
Perform a simple HTTP HEAD request. No SSL support.
:: MonadIO m | |
=> String | URL |
-> SSLContext | SSL Context |
-> m (HttpResp m) |
Perform a simple HTTPS HEAD request.
Advanced interface
data HttpClient Source
An HTTP client.
HttpClient | |
|
:: S | Host |
-> Int | Port |
-> Maybe SSLContext | SSL context |
-> Bool | Is HTTPS |
-> IO HttpClient |
Given the host, port, context, and "is-https" flag, create
a client value. The returned value can be used with httpConnect
to get raw pipes to/from the server.
Note: Some of this code is from the HTTP package.
httpConnect :: MonadIO m => HttpClient -> IO (Iter L m (), Onum L m a)Source
Given an HTTP client configuration, make the actual connection to server.
inumHttpClient :: MonadIO m => (HttpReq s, L) -> HttpResponseHandler m s -> Inum L L m aSource
Given an initial request, and a response handler, create an inum that provides underlying functionality of an http client.
type HttpResponseHandler m s = HttpResp m -> Iter L m (Maybe (HttpReq s, L))Source
An HTTP response handler used by HTTP clients.
Internal
Maximum number of redirects. Defult: no redirect (0).
mkRequestToAbsUri :: Monad m => L -> S -> m (HttpReq ())Source
Createa generic HTTP request, given an absoluteURI: If the URI is not absolute, the parser will fail.