http-interchange-0.3.2.1: Types and serialization for HTTP
Safe HaskellSafe-Inferred
LanguageGHC2021

Http.Headers

Synopsis

Types

data Headers Source #

Collection of HTTP headers. Supports case-insensitive lookup. This is intended to be used for small collections of headers. Expect degraded performance if this is used for collections of more than 128 headers.

This preserves the original order of the headers and the original case of the header names.

Instances

Instances details
Monoid Headers Source # 
Instance details

Defined in Http.Headers

Semigroup Headers Source # 
Instance details

Defined in Http.Headers

Show Headers Source # 
Instance details

Defined in Http.Headers

Eq Headers Source # 
Instance details

Defined in Http.Headers

Methods

(==) :: Headers -> Headers -> Bool #

(/=) :: Headers -> Headers -> Bool #

data LookupException Source #

Many headers cannot appear more than once. This is part of the return type for lookup, and it helps us track whether the lookup failure was the result of something that might be expected (the header was Missing) or something that is definitely a mistake (the header was duplicated).

Constructors

Duplicate 
Missing 

Instances

Instances details
Show LookupException Source # 
Instance details

Defined in Http.Headers

Eq LookupException Source # 
Instance details

Defined in Http.Headers

Construct

fromArray :: SmallArray Header -> Headers Source #

Convert array of headers to a Headers collection that supports efficient lookup.

fromList :: [Header] -> Headers Source #

Convert list of headers to a Headers collection that supports efficient lookup.

Modify

cons :: Header -> Headers -> Headers Source #

Add a header to the beginning of the headers.

snoc :: Headers -> Header -> Headers Source #

Add a header to the beginning of the headers.

Expose

toArray :: Headers -> SmallArray Header Source #

Recover the original headers from from the Headers collection. This is O(1) and is most commonly used to fold over the headers.

Lookup

lookup :: Text -> Headers -> Either LookupException Header Source #

Lookup a header that should not appear more than one time and verify that it did not occur more than once. If it appears more than once (or less than once), returns a LookupException.

lookupFirst :: Text -> Headers -> Maybe Header Source #

Case insensitive lookup of an HTTP header. If the header is present, returns both the original header name (may differs in case from the header name searched for) and the header value. Only returns the first occurrence of the header.

lookupAll :: Text -> Headers -> SmallArray Header Source #

Lookup a header that may appear more than once. Some headers (e.g. Set-Cookie, X-Forwarded-For) are allowed to appear multiple times. This returns all the headers that matched along with their original names.

Specialized Lookup

Specialized Snoc

Specialized Absence

lacksContentLengthAndTransferEncoding :: Headers -> Bool Source #

Returns True if both the Content-Length and Transfer-Encoding headers are missing.