Safe Haskell | None |
---|---|
Language | Haskell98 |
Internal constructors and helper functions. Note that no guarantees are given for stability of these interfaces.
- 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
- data Response
- type StreamingBody = (Builder -> IO ()) -> IO () -> IO ()
- data RequestBodyLength
- data FilePart = FilePart {}
- data ResponseReceived = ResponseReceived
- tryGetFileSize :: FilePath -> IO (Either IOException Integer)
- hContentRange :: HeaderName
- hAcceptRanges :: HeaderName
- contentRangeHeader :: Integer -> Integer -> Integer -> Header
- chooseFilePart :: Integer -> Maybe ByteString -> FilePart
- adjustForFilePart :: Status -> ResponseHeaders -> FilePart -> (Status, ResponseHeaders)
- parseByteRanges :: ByteString -> Maybe ByteRanges
Documentation
Information on the request sent by the client. This abstracts away the details of the underlying implementation.
Request | |
|
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
Information on which part to be sent.
Sophisticated application handles Range (and If-Range) then
create FilePart
.
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
tryGetFileSize :: FilePath -> IO (Either IOException Integer) Source
Look up the size of a file in Right
or the IOException
in Left
.
hContentRange :: HeaderName Source
"Content-Range".
hAcceptRanges :: HeaderName Source
"Accept-Ranges".
contentRangeHeader :: Integer -> Integer -> Integer -> Header Source
contentRangeHeader beg end total
constructs a Content-Range Header
for the range specified.
chooseFilePart :: Integer -> Maybe ByteString -> FilePart Source
Given the full size of a file and optionally a Range header value, determine the range to serve by parsing the range header and obeying it, or serving the whole file if it's absent or malformed.
adjustForFilePart :: Status -> ResponseHeaders -> FilePart -> (Status, ResponseHeaders) Source
Adjust the given Status
and ResponseHeaders
based on the given
FilePart
. This means replacing the status with 206 if the response is
partial, and adding the Content-Length and Accept-Ranges (always) and
Content-Range (if appropriate) headers.
parseByteRanges :: ByteString -> Maybe ByteRanges Source
Parse the value of a Range header into a ByteRanges
.