wai-3.2.4: Web Application Interface.

Safe Haskell | None
Language | Haskell2010

Network.Wai.Internal

Description

Internal constructors and helper functions. Note that no guarantees are given for stability of these interfaces.

Synopsis

- data Request = Request {
  - requestMethod :: Method
  - httpVersion :: HttpVersion
  - rawPathInfo :: ByteString
  - rawQueryString :: ByteString
  - requestHeaders :: RequestHeaders
  - isSecure :: Bool
  - remoteHost :: SockAddr
  - pathInfo :: [Text]
  - queryString :: Query
  - requestBody :: IO ByteString
  - vault :: Vault
  - requestBodyLength :: RequestBodyLength
  - requestHeaderHost :: Maybe ByteString
  - requestHeaderRange :: Maybe ByteString
  - requestHeaderReferer :: Maybe ByteString
  - requestHeaderUserAgent :: Maybe ByteString
  }
- getRequestBodyChunk :: Request -> IO ByteString
- setRequestBodyChunks :: IO ByteString -> Request -> Request
- data Response
  - = ResponseFile Status ResponseHeaders FilePath (Maybe FilePart)
  - | ResponseBuilder Status ResponseHeaders Builder
  - | ResponseStream Status ResponseHeaders StreamingBody
  - | ResponseRaw (IO ByteString -> (ByteString -> IO ()) -> IO ()) Response
- type StreamingBody = (Builder -> IO ()) -> IO () -> IO ()
- data RequestBodyLength
  - = ChunkedBody
  - | KnownLength Word64
- data FilePart = FilePart {
  - filePartOffset :: Integer
  - filePartByteCount :: Integer
  - filePartFileSize :: Integer
  }
- data ResponseReceived = ResponseReceived

# Documentation

data Request Source #

Information on the request sent by the client. This abstracts away the details of the underlying implementation.

Constructors

Request |

Fields

- requestMethod :: Method

  Request method such as GET.

- httpVersion :: HttpVersion

  HTTP version such as 1.1.

- rawPathInfo :: ByteString

  Extra path information sent by the client. The meaning varies slightly depending on backend; in a standalone server setting, this is most likely all information after the domain name. In a CGI application, this would be the information following the path to the CGI executable itself.

  Middlewares and routing tools should not modify this raw value, as it may be used for such things as creating redirect destinations by applications. Instead, if you are writing a middleware or routing framework, modify the `pathInfo` instead. This is the approach taken by systems like Yesod subsites.

  Note: At the time of writing this documentation, there is at least one system (`Network.Wai.UrlMap` from `wai-extra`) that does not follow the above recommendation. Therefore, it is recommended that you test the behavior of your application when using `rawPathInfo` and any form of library that might modify the `Request`.

- rawQueryString :: ByteString

  If no query string was specified, this should be empty. This value will include the leading question mark. Do not modify this raw value - modify queryString instead.

- requestHeaders :: RequestHeaders

  A list of headers (a pair of key and value) in an HTTP request.

- isSecure :: Bool

  Was this request made over an SSL connection?

  Note that this value will not tell you if the client originally made this request over SSL, but rather whether the current connection is SSL. The distinction lies with reverse proxies. In many cases, the client will connect to a load balancer over SSL, but connect to the WAI handler without SSL. In such a case, `isSecure` will be `False`, but from a user perspective, there is a secure connection.

- remoteHost :: SockAddr

  The client's host information.

- pathInfo :: [Text]

  Path info in individual pieces - the URL without a hostname/port and without a query string, split on forward slashes.

- queryString :: Query

  Parsed query string information.

- requestBody :: IO ByteString

  Deprecated: requestBody's name is misleading because it only gets a partial chunk of the body. Use getRequestBodyChunk instead when getting the field, and setRequestBodyChunks when setting the field.

  Get the next chunk of the body. Returns `empty` when the body is fully consumed. Since 3.2.2, this is deprecated in favor of `getRequestBodyChunk`.

- vault :: Vault

  A location for arbitrary data to be shared by applications and middleware.

- requestBodyLength :: RequestBodyLength

  The size of the request body. In the case of a chunked request body, this may be unknown.

  Since: 1.4.0

- requestHeaderHost :: Maybe ByteString

  The value of the Host header in a HTTP request.

  Since: 2.0.0

- requestHeaderRange :: Maybe ByteString

  The value of the Range header in a HTTP request.

  Since: 2.0.0

- requestHeaderReferer :: Maybe ByteString

  The value of the Referer header in a HTTP request.

  Since: 3.2.0

- requestHeaderUserAgent :: Maybe ByteString

  The value of the User-Agent header in a HTTP request.

  Since: 3.2.0

#### Instances

Instances details

Show Request Source # |
Instance details Defined in Network.Wai.Internal Methods showsPrec :: Int -> Request -> ShowS Source # show :: Request -> String Source # showList :: [Request] -> ShowS Source #

getRequestBodyChunk :: Request -> IO ByteString Source #

Get the next chunk of the body. Returns `empty` when the body is fully consumed.

Since: 3.2.2

setRequestBodyChunks :: IO ByteString -> Request -> Request Source #

Set the `requestBody` attribute on a request without triggering a deprecation warning.

The supplied IO action should return the next chunk of the body each time it is called and `empty` when it has been fully consumed.

Since: 3.2.4

data Response Source #

Constructors

ResponseFile Status ResponseHeaders FilePath (Maybe FilePart) |
ResponseBuilder Status ResponseHeaders Builder |
ResponseStream Status ResponseHeaders StreamingBody |
ResponseRaw (IO ByteString -> (ByteString -> IO ()) -> IO ()) Response |

type StreamingBody = (Builder -> IO ()) -> IO () -> IO () Source #

Represents a streaming HTTP response body. It's a function of two parameters; the first parameter provides a means of sending another chunk of data, and the second parameter provides a means of flushing the data to the client.

Since: 3.0.0

data RequestBodyLength Source #

The size of the request body. In the case of chunked bodies, the size will not be known.

Since: 1.4.0

Constructors

ChunkedBody |
KnownLength Word64 |

#### Instances

Instances details

Show RequestBodyLength Source # |
Instance details Defined in Network.Wai.Internal Methods showsPrec :: Int -> RequestBodyLength -> ShowS Source # show :: RequestBodyLength -> String Source # showList :: [RequestBodyLength] -> ShowS Source #

data FilePart Source #

Information on which part to be sent. Sophisticated application handles Range (and If-Range) then create `FilePart`.

Since: 0.4.0

Constructors

FilePart |

Fields

- filePartOffset :: Integer
- filePartByteCount :: Integer
- filePartFileSize :: Integer

#### Instances

Instances details

Show FilePart Source # |
Instance details Defined in Network.Wai.Internal Methods showsPrec :: Int -> FilePart -> ShowS Source # show :: FilePart -> String Source # showList :: [FilePart] -> ShowS Source #

data ResponseReceived Source #

A special datatype to indicate that the WAI handler has received the response. This is to avoid the need for Rank2Types in the definition of Application.

It is highly advised that only WAI handlers import and use the data constructor for this data type.

Since: 3.0.0

Constructors

ResponseReceived |