Network.Wai.Header

wai-extra-3.1.17: Provides some basic WAI handlers and middleware.

Safe Haskell | None
Language | Haskell2010

Network.Wai.Header

Description

Some helpers for dealing with WAI `Header`s.

Synopsis

- contentLength :: [(HeaderName, ByteString)] -> Maybe Integer
- parseQValueList :: ByteString -> [(ByteString, Maybe Int)]
- replaceHeader :: HeaderName -> ByteString -> [Header] -> [Header]

# Documentation

contentLength :: [(HeaderName, ByteString)] -> Maybe Integer #

More useful for a response. A Wai Request already has a requestBodyLength

parseQValueList :: ByteString -> [(ByteString, Maybe Int)] #

Only to be used on header's values which support quality value syntax

A few things to keep in mind when using this function: * The resulting `Int` will be anywhere from 1000 to 0 ("1" = 1000, "0.6" = 600, "0.025" = 25) * The absence of a Q value will result in 'Just 1000' * A bad parse of the Q value will result in a `Nothing`, e.g. * Q value has more than 3 digits behind the dot * Q value is missing * Q value is higher than 1 * Q value is not a number

replaceHeader :: HeaderName -> ByteString -> [Header] -> [Header] #