HTTP-3001.0.4Source codeContentsIndex
Network.HTTP.Headers
Portabilitynon-portable (not tested)
Stabilityexperimental
Maintainerbjorn@bringert.net
Description
  • Changes by Robin Bate Boerop robin@bateboerop.name: - 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:
Host
Required by HTTP/1.1, if not supplied as part of a request a default Host value is extracted from the request-uri.
Connection
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.
Expect
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.
TransferEncoding,ContentLength,...
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).
Synopsis
class HasHeaders x where
getHeaders :: x -> [Header]
setHeaders :: x -> [Header] -> x
data Header = Header HeaderName String
data HeaderName
= HdrCacheControl
| HdrConnection
| HdrDate
| HdrPragma
| HdrTransferEncoding
| HdrUpgrade
| HdrVia
| HdrAccept
| HdrAcceptCharset
| HdrAcceptEncoding
| HdrAcceptLanguage
| HdrAuthorization
| HdrCookie
| HdrExpect
| HdrFrom
| HdrHost
| HdrIfModifiedSince
| HdrIfMatch
| HdrIfNoneMatch
| HdrIfRange
| HdrIfUnmodifiedSince
| HdrMaxForwards
| HdrProxyAuthorization
| HdrRange
| HdrReferer
| HdrUserAgent
| HdrAge
| HdrLocation
| HdrProxyAuthenticate
| HdrPublic
| HdrRetryAfter
| HdrServer
| HdrSetCookie
| HdrVary
| HdrWarning
| HdrWWWAuthenticate
| HdrAllow
| HdrContentBase
| HdrContentEncoding
| HdrContentLanguage
| HdrContentLength
| HdrContentLocation
| HdrContentMD5
| HdrContentRange
| HdrContentType
| HdrETag
| HdrExpires
| HdrLastModified
| HdrContentTransferEncoding
| HdrCustom String
insertHeader :: HasHeaders a => HeaderName -> String -> a -> a
insertHeaderIfMissing :: HasHeaders a => HeaderName -> String -> a -> a
insertHeaders :: HasHeaders a => [Header] -> a -> a
retrieveHeaders :: HasHeaders a => HeaderName -> a -> [Header]
replaceHeader :: HasHeaders a => HeaderName -> String -> a -> a
findHeader :: HasHeaders a => HeaderName -> a -> Maybe String
lookupHeader :: HeaderName -> [Header] -> Maybe String
parseHeaders :: [String] -> Result [Header]
Documentation
class HasHeaders x whereSource
This class allows us to write generic header manipulation functions for both Request and Response data types.
Methods
getHeaders :: x -> [Header]Source
setHeaders :: x -> [Header] -> xSource
show/hide Instances
data Header Source
The Header data type pairs header names & values.
Constructors
Header HeaderName String
show/hide Instances
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.

Constructors
HdrCacheControl
HdrConnection
HdrDate
HdrPragma
HdrTransferEncoding
HdrUpgrade
HdrVia
HdrAccept
HdrAcceptCharset
HdrAcceptEncoding
HdrAcceptLanguage
HdrAuthorization
HdrCookie
HdrExpect
HdrFrom
HdrHost
HdrIfModifiedSince
HdrIfMatch
HdrIfNoneMatch
HdrIfRange
HdrIfUnmodifiedSince
HdrMaxForwards
HdrProxyAuthorization
HdrRange
HdrReferer
HdrUserAgent
HdrAge
HdrLocation
HdrProxyAuthenticate
HdrPublic
HdrRetryAfter
HdrServer
HdrSetCookie
HdrVary
HdrWarning
HdrWWWAuthenticate
HdrAllow
HdrContentBase
HdrContentEncoding
HdrContentLanguage
HdrContentLength
HdrContentLocation
HdrContentMD5
HdrContentRange
HdrContentType
HdrETag
HdrExpires
HdrLastModified
HdrContentTransferEncoding
HdrCustom StringAllows for unrecognised or experimental headers.
show/hide Instances
insertHeader :: HasHeaders a => HeaderName -> String -> a -> aSource
insertHeaderIfMissing :: HasHeaders a => HeaderName -> String -> a -> aSource
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.
replaceHeader :: HasHeaders a => HeaderName -> String -> a -> aSource
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.
lookupHeader :: HeaderName -> [Header] -> Maybe StringSource
parseHeaders :: [String] -> Result [Header]Source
Produced by Haddock version 2.6.0