Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Synopsis
- data Headers
- data LookupException
- fromArray :: SmallArray Header -> Headers
- fromList :: [Header] -> Headers
- cons :: Header -> Headers -> Headers
- snoc :: Headers -> Header -> Headers
- toArray :: Headers -> SmallArray Header
- lookup :: Text -> Headers -> Either LookupException Header
- lookupFirst :: Text -> Headers -> Maybe Header
- lookupAll :: Text -> Headers -> SmallArray Header
- lookupLocation :: Headers -> Either LookupException Header
- lookupContentType :: Headers -> Either LookupException Header
- lookupContentLength :: Headers -> Either LookupException Header
- lookupTransferEncoding :: Headers -> Either LookupException Header
- lookupHost :: Headers -> Either LookupException Header
- lookupAccept :: Headers -> Either LookupException Header
- lookupDate :: Headers -> Either LookupException Header
- snocContentLength :: Headers -> Text -> Headers
- lacksContentLengthAndTransferEncoding :: Headers -> Bool
Types
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.
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).
Instances
Show LookupException Source # | |
Defined in Http.Headers showsPrec :: Int -> LookupException -> ShowS # show :: LookupException -> String # showList :: [LookupException] -> ShowS # | |
Eq LookupException Source # | |
Defined in Http.Headers (==) :: LookupException -> LookupException -> Bool # (/=) :: LookupException -> LookupException -> Bool # |
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
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.