http-client-0.1.0.0: An HTTP client engine, intended as a base layer for more user-friendly packages.

Safe HaskellNone

Network.HTTP.Client.Types

Synopsis

Documentation

data Connection Source

Constructors

Connection 

Fields

connectionRead :: !(IO ByteString)

If no more data, return empty.

connectionUnread :: !(ByteString -> IO ())

Return data to be read next time.

connectionWrite :: !(ByteString -> IO ())

Send data to server

connectionClose :: !(IO ())
 

newtype CookieJar Source

Constructors

CJ 

Fields

expose :: [Cookie]
 

data Proxy Source

Define a HTTP proxy, consisting of a hostname and port number.

Constructors

Proxy 

Fields

proxyHost :: ByteString

The host name of the HTTP proxy.

proxyPort :: Int

The port number of the HTTP proxy.

data RequestBody Source

When using one of the RequestBodySource / RequestBodySourceChunked constructors, you must ensure that the Source can be called multiple times. Usually this is not a problem.

The RequestBodySourceChunked will send a chunked request body, note that not all servers support this. Only use RequestBodySourceChunked if you know the server you're sending to supports chunked request bodies.

Instances

data Request Source

All information on how to connect to a host and what should be sent in the HTTP request.

If you simply wish to download from a URL, see parseUrl.

The constructor for this data type is not exposed. Instead, you should use either the def method to retrieve a default instance, or parseUrl to construct from a URL, and then use the records below to make modifications. This approach allows http-conduit to add configuration options without breaking backwards compatibility.

For example, to construct a POST request, you could do something like:

 initReq <- parseUrl "http://www.example.com/path"
 let req = initReq
             { method = "POST"
             }

For more information, please see http://www.yesodweb.com/book/settings-types.

Constructors

Request 

Fields

method :: Method

HTTP request method, eg GET, POST.

secure :: Bool

Whether to use HTTPS (ie, SSL).

host :: ByteString
 
port :: Int
 
path :: ByteString

Everything from the host to the query string.

queryString :: ByteString
 
requestHeaders :: RequestHeaders

Custom HTTP request headers

As already stated in the introduction, the Content-Length and Host headers are set automatically by this module, and shall not be added to requestHeaders.

Moreover, the Accept-Encoding header is set implicitly to gzip for convenience by default. This behaviour can be overridden if needed, by setting the header explicitly to a different value. In order to omit the Accept-Header altogether, set it to the empty string "". If you need an empty Accept-Header (i.e. requesting the identity encoding), set it to a non-empty white-space string, e.g. " ". See RFC 2616 section 14.3 for details about the semantics of the Accept-Header field. If you request a content-encoding not supported by this module, you will have to decode it yourself (see also the decompress field).

Note: Multiple header fields with the same field-name will result in multiple header fields being sent and therefore it's the responsibility of the client code to ensure that the rules from RFC 2616 section 4.2 are honoured.

requestBody :: RequestBody
 
proxy :: Maybe Proxy

Optional HTTP proxy.

hostAddress :: Maybe HostAddress

Optional resolved host address.

Since 1.8.9

rawBody :: Bool

If True, a chunked and/or gzipped body will not be decoded. Use with caution.

decompress :: ContentType -> Bool

Predicate to specify whether gzipped data should be decompressed on the fly (see alwaysDecompress and browserDecompress). Default: browserDecompress.

redirectCount :: Int

How many redirects to follow when getting a resource. 0 means follow no redirects. Default value: 10.

checkStatus :: Status -> ResponseHeaders -> CookieJar -> Maybe SomeException

Check the status code. Note that this will run after all redirects are performed. Default: return a StatusCodeException on non-2XX responses.

responseTimeout :: Maybe Int

Number of microseconds to wait for a response. If Nothing, will wait indefinitely. Default: 5 seconds.

getConnectionWrapper :: Maybe Int -> HttpException -> IO (ConnRelease, Connection, ManagedConn) -> IO (Maybe Int, (ConnRelease, Connection, ManagedConn))

Wraps the calls for getting new connections. This can be useful for instituting some kind of timeouts. The first argument is the value of responseTimeout. Second argument is the exception to be thrown on failure.

Default: If responseTimeout is Nothing, does nothing. Otherwise, institutes timeout, and returns remaining time for responseTimeout.

Since 1.8.8

cookieJar :: Maybe CookieJar

A user-defined cookie jar. If Nothing, no cookie handling will take place, "Cookie" headers in requestHeaders will be sent raw, and responseCookieJar will be empty.

Since 1.9.0

data ConnReuse Source

Constructors

Reuse 
DontReuse 

data ManagedConn Source

Constructors

Fresh 
Reused 

data Response body Source

A simple representation of the HTTP response created by lbsConsumer.

Constructors

Response 

Fields

responseStatus :: !Status

Status code of the response.

responseVersion :: !HttpVersion

HTTP version used by the server.

responseHeaders :: !ResponseHeaders

Response headers sent by the server.

responseBody :: !body

Response body sent by the server.

responseCookieJar :: !CookieJar

Cookies set on the client after interacting with the server. If cookies have been disabled by setting cookieJar to Nothing, then this will always be empty.

responseClose' :: !ResponseClose

Releases any resource held by this response. If the response body has not been fully read yet, doing so after this call will likely be impossible.

Instances

Functor Response 
Typeable1 Response 
Eq body => Eq (Response body) 
Show body => Show (Response body)