HTTP-4000.0.2: A library for client-side HTTP

Portabilitynon-portable (not tested)



  • Changes by Robin Bate Boerop - Made dependencies explicit in import statements. - Removed false dependencies in import statements. - Added missing type signatures. - Created Network.HTTP.Headers from Network.HTTP modules.

See changes history and TODO list in Network.HTTP module.

  • Header notes:
Required by HTTP/1.1, if not supplied as part of a request a default Host value is extracted from the request-uri.
If this header is present in any request or response, and it's value is close, then the current request/response is the last to be allowed on that connection.
Should a request contain a body, an Expect header will be added to the request. The added header has the value "100-continue". After a 417 "Expectation Failed" response the request is attempted again without this added Expect header.
if request is inconsistent with any of these header values then you may not receive any response or will generate an error response (probably 4xx).



class HasHeaders x whereSource

This class allows us to write generic header manipulation functions for both Request and Response data types.


getHeaders :: x -> [Header]Source

setHeaders :: x -> [Header] -> xSource

data Header Source

The Header data type pairs header names & values.


Header HeaderName String 


data HeaderName Source

HTTP Header Name type: Why include this at all? I have some reasons 1) prevent spelling errors of header names, 2) remind everyone of what headers are available, 3) might speed up searches for specific headers.

Arguments against: 1) makes customising header names laborious 2) increases code volume.

Long discussions can be had on this topic!

insertHeaders :: HasHeaders a => [Header] -> a -> aSource

Inserts a header with the given name and value. Allows duplicate header names.

Adds the new header only if no previous header shares the same name.

Removes old headers with duplicate name.

Inserts multiple headers.

retrieveHeaders :: HasHeaders a => HeaderName -> a -> [Header]Source

Gets a list of headers with a particular HeaderName.

findHeader :: HasHeaders a => HeaderName -> a -> Maybe StringSource

Lookup presence of specific HeaderName in a list of Headers Returns the value from the first matching header.