Safe Haskell | None |
---|
- data Response a = Response {
- responseStatus :: Status
- responseHeaders :: [Header]
- responseBody :: a
- readResponse :: Bool -> Method -> InputStream -> IO (Response BodyReader)
- readResponseWithLimit :: Limit -> Bool -> Method -> InputStream -> IO (Response BodyReader)
- parseStatusLine :: ByteString -> Maybe Status
- simpleResponse :: (ByteString -> IO ()) -> Status -> [Header] -> ByteString -> IO ()
- sendResponse :: (ByteString -> IO ()) -> Response BodyReader -> IO ()
- formatStatusLine :: Status -> ByteString
- determineResponseBodyType :: Method -> Status -> [Header] -> BodyType
Documentation
Response | |
|
readResponse :: Bool -> Method -> InputStream -> IO (Response BodyReader)Source
Same as readResponseWithLimit
with a Limit
of
defaultHeaderSizeLimit
.
readResponseWithLimit :: Limit -> Bool -> Method -> InputStream -> IO (Response BodyReader)Source
Read response from provided InputStream
.
The second argument is passed to makeChunkedReader
.
The corresponding request Method
has to be specified so that the body length can be determined (see
RFC 2616, Section 4.4).
Throws:
-
InvalidStatusLine
if status-line is malformed. -
HeaderTooLarge
if status-line and headers together exceed the specified sizeLimit
-
InvalidHeader
if status-line is missing or a header is malformed
parseStatusLine :: ByteString -> Maybe StatusSource
Parse status-line (see RFC 2616, Section 6.1).
simpleResponse :: (ByteString -> IO ()) -> Status -> [Header] -> ByteString -> IO ()Source
Send a simple HTTP response. The provided ByteString
is used as the
message body. A suitable Content-Length
header is added to the specified
list of headers.
Note: The first argument to this function is used to send the data. For space efficiency it may be called multiple times.
sendResponse :: (ByteString -> IO ()) -> Response BodyReader -> IO ()Source
Send an HTTP response.
Note: The first argument to this function is used to send the data. For space efficiency it may be called multiple times.
formatStatusLine :: Status -> ByteStringSource
Format status-line.
determineResponseBodyType :: Method -> Status -> [Header] -> BodyTypeSource
Determine the message BodyType
from a given Method
, Status
, and list
of message headers (as of
RFC 2616, Section 4.4).