iterIO-0.2.2: Iteratee-based IO with pipe operators

Safe HaskellSafe-Infered

Data.IterIO.HttpClient

Contents

Synopsis

Simple interface

simpleHttpSource

Arguments

:: 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.

genSimpleHttpSource

Arguments

:: 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.

postRequestSource

Arguments

:: String

URL

-> String

Content-Type header

-> L

Message body

-> HttpReq () 

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

simpleGetHttpSource

Arguments

:: MonadIO m 
=> String

URL

-> m (HttpResp m) 

Perform a simple HTTP GET request. No SSL support.

simpleGetHttpsSource

Arguments

:: MonadIO m 
=> String

URL

-> SSLContext

SSL Context

-> m (HttpResp m) 

Perform a simple HTTPS GET request.

simpleHeadHttpSource

Arguments

:: MonadIO m 
=> String

URL

-> m (HttpResp m) 

Perform a simple HTTP HEAD request. No SSL support.

simpleHeadHttpsSource

Arguments

:: MonadIO m 
=> String

URL

-> SSLContext

SSL Context

-> m (HttpResp m) 

Perform a simple HTTPS HEAD request.

Advanced interface

data HttpClient Source

An HTTP client.

Constructors

HttpClient 

Fields

hcSock :: !Socket

Socket

hcSockAddr :: !SockAddr

Socket address

hcSslCtx :: !(Maybe SSLContext)

SSL context

hcIsHttps :: !Bool

Use SSL

mkHttpClientSource

Arguments

:: 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

userAgent :: StringSource

User agent corresponding to this library.

maxNrRedirects :: IntSource

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.