Network.Wai.Request

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

Safe Haskell | None
Language | Haskell2010

Network.Wai.Request

Description

Some helpers for interrogating a WAI `Request`.

Synopsis

- appearsSecure :: Request -> Bool
- guessApproot :: Request -> ByteString
- newtype RequestSizeException = RequestSizeException Word64
- requestSizeCheck :: Word64 -> Request -> IO Request

# Documentation

appearsSecure :: Request -> Bool #

Does this request appear to have been made over an SSL connection?

This function first checks ``isSecure``, but also checks for headers that may indicate a secure connection even in the presence of reverse proxies.

Note: these headers can be easily spoofed, so decisions which require a true SSL connection (i.e. sending sensitive information) should only use ``isSecure``. This is not always the case though: for example, deciding to force a non-SSL request to SSL by redirect. One can safely choose not to redirect when the request appears secure, even if it's actually not.

Since: 3.0.7

guessApproot :: Request -> ByteString #

Guess the "application root" based on the given request.

The application root is the basis for forming URLs pointing at the current application. For more information and relevant caveats, please see Network.Wai.Middleware.Approot.

Since: 3.0.7

newtype RequestSizeException #

see `requestSizeCheck`

Since: 3.0.15

Constructors

RequestSizeException Word64 |

#### Instances

Instances details

Exception RequestSizeException # |
Instance details Defined in Network.Wai.Request Methods toException :: RequestSizeException -> SomeException # fromException :: SomeException -> Maybe RequestSizeException # displayException :: RequestSizeException -> String # backtraceDesired :: RequestSizeException -> Bool #
Show RequestSizeException # |
Instance details Defined in Network.Wai.Request Methods showsPrec :: Int -> RequestSizeException -> ShowS # show :: RequestSizeException -> String # showList :: [RequestSizeException] -> ShowS #
Eq RequestSizeException # |
Instance details Defined in Network.Wai.Request Methods (==) :: RequestSizeException -> RequestSizeException -> Bool # (/=) :: RequestSizeException -> RequestSizeException -> Bool #
Ord RequestSizeException # |
Instance details Defined in Network.Wai.Request Methods compare :: RequestSizeException -> RequestSizeException -> Ordering # (<) :: RequestSizeException -> RequestSizeException -> Bool # (<=) :: RequestSizeException -> RequestSizeException -> Bool # (>) :: RequestSizeException -> RequestSizeException -> Bool # (>=) :: RequestSizeException -> RequestSizeException -> Bool # max :: RequestSizeException -> RequestSizeException -> RequestSizeException # min :: RequestSizeException -> RequestSizeException -> RequestSizeException #

requestSizeCheck :: Word64 -> Request -> IO Request #

Check request body size to avoid server crash when request is too large.

This function first checks ``requestBodyLength``, if content-length is known but larger than limit, or it's unknown but we have received too many chunks, a `RequestSizeException` are thrown when user use ``requestBody`` to extract request body inside IO.

Since: 3.0.15