This module contains everything you need to initiate HTTP connections.
Make sure to wrap your code with withHttpEnumerator. If you want a simple
interface based on URLs, you can use simpleHttp. If you want raw power,
http is the underlying workhorse of this package. Some examples:

The following headers are automatically set by this module, and should not
be added to requestHeaders:

Content-Length

Host

Accept-Encoding (not currently set, but client usage of this variable will cause breakage).

One last thing: there are two different backends available for the HTTPS
support: the OpenSSL library and the tls package. The former requires some
initialization, while the latter does not. Therefore, this module exports a
withHttpEnumerator function to provide necessary initialization.
Additionally, any network code on Windows requires some initialization, and
the network library provides withSocketsDo to perform it. Therefore, proper
usage of this library will always involve calling those two functions at
some point. The best approach is to simply call them at the beginning of
your main function, such as:

This is a simplified version of http for the common case where you simply
want the response data as a simple datatype. If you want more power, such as
interleaved actions on the response body during download, you'll need to use
http directly. This function is defined as:

httpLbs = http lbsIter

Please see lbsIter for more information on how the Response value is
created.

Download the specified Request, returning the results as a Response
and automatically handling redirects.

This is a simplified version of httpRedirect for the common case where you
simply want the response data as a simple datatype. If you want more power,
such as interleaved actions on the response body during download, you'll
need to use httpRedirect directly. This function is defined as:

httpLbsRedirect = httpRedirect lbsIter

Please see lbsIter for more information on how the Response value is
created.

The second argument to this function gives a full specification on the
request: the host to connect to, whether to use SSL, headers, etc. Please
see Request for full details.

The first argument specifies how the response should be handled. It's a
function that takes two arguments: the first is the HTTP status code of the
response, and the second is a list of all response headers. This module
exports lbsIter, which generates a Response value.

Note that this allows you to have fully interleaved IO actions during your
HTTP download, making it possible to download very large responses in
constant memory.

The OpenSSL library requires some initialization of variables to be used,
and therefore you must call withOpenSSL before using any of its functions.
As this library uses OpenSSL, you must use withOpenSSL as well. (As a side
note, you'll also want to use the withSocketsDo function for network
activity.)

To future-proof this package against switching to different SSL libraries,
we re-export withOpenSSL under this name. You can call this function as
early as you like; in fact, simply wrapping the do block of your main
function is probably best.

Even though a Response contains a lazy bytestring, this function does
not utilize lazy I/O, and therefore the entire response body will live in
memory. If you want constant memory usage, you'll need to write your own
iteratee and use http or httpRedirect directly.