salvia-1.0.0: Modular web application framework.

Network.Salvia.Handler.Body

Synopsis

Documentation

hRawRequestBody :: BodyM Request m => m ByteStringSource

Like hRawBody but specifically for Http Requests.

hRawResponseBody :: BodyM Response m => m ByteStringSource

Like hRawBody but specifically for Http Requests.

hRawBody :: forall m d. (MonadIO m, HandleM m, HttpM d m) => d -> m ByteStringSource

First (possibly naive) handler to retreive the client request or server response body as a raw lazy ByteString. This probably does not handle all the quirks that the HTTP protocol specifies, but it does the job for now. When a contentLength header field is available only this fixed number of bytes will read from the socket. When neither the keepAlive and contentLength header fields are available the entire payload of the request will be read from the socket. The function is parametrized with a the direction of the HTTP message, client request or server response.

hRequestBodyText :: (BodyM Request m, HttpM Request m) => String -> m TextSource

Like hBodyText but specifically for Http Requests.

hResponseBodyText :: (BodyM Response m, HttpM Response m) => String -> m TextSource

Like hBodyText but specifically for Http Responses.

hBodyText :: forall m dir. (BodyM dir m, HttpM dir m) => dir -> String -> m TextSource

Like the hRawBody but is will handle proper decoding based on the charset part of the contentType header line. When a valid encoding is found in the Http message it will be decoded with using the encodings package. The default encoding supplied as the function's argument can be used to specify what encoding to use in the absence of a proper encoding in the HTTP message itself.

hBodyStringUTF8 :: BodyM dir m => dir -> m StringSource

Like the hRawBody but decodes it as UTF-8 to a String.

hRequestParameters :: (BodyM Request m, HttpM Request m) => String -> m ParametersSource

Like hParameters but specifically for HTTP Requests.

hResponseParameters :: (BodyM Response m, HttpM Response m) => String -> m ParametersSource

Like hParameters but specifically for HTTP Responses.

hParameters :: (BodyM d m, HttpM d m) => d -> String -> m ParametersSource

Try to parse the message body, as a result of hBodyText, as URI encoded POST parameters. Returns as a URI Parameter type or nothing when parsing fails.