Safe Haskell | None |
---|---|
Language | Haskell2010 |
Encoding and decoding of bodies and complete HTTP messages. See
package jespresso
for an example of usage.
- decode :: (HasHeaders (m ByteString), HasHeaders (m String), HasBody m) => m ByteString -> Either EncodingError (String, m String)
- encode :: (HasHeaders (m String), HasBody m) => EncodingName -> m String -> Either EncodingError (m ByteString)
- withDecodedBody :: (HasHeaders (r String), HasHeaders (r ByteString), HasBody r) => (String -> String) -> r ByteString -> Either EncodingError (r ByteString)
- withDecodedBodyM :: (Monad m, HasHeaders (r String), HasHeaders (r ByteString), HasBody r) => (String -> m String) -> r ByteString -> m (Either EncodingError (r ByteString))
- decodeBody :: (HasHeaders (r ByteString), HasBody r) => r ByteString -> Either EncodingError DecodingResult
- encodeBody :: EncodingName -> ContentEncoding -> String -> Either EncodingError ByteString
- class HasBody a where
- data EncodingError
- data DecodingResult = DecodingResult {}
Operations on HTTP messages
decode :: (HasHeaders (m ByteString), HasHeaders (m String), HasBody m) => m ByteString -> Either EncodingError (String, m String) Source
Decode the body of an HTTP message and return the original encoding name and the same message with decoded body (as UTF8-encoded string) and updated character and content encoding headers.
encode :: (HasHeaders (m String), HasBody m) => EncodingName -> m String -> Either EncodingError (m ByteString) Source
Encode the UTF8-encoded body of an HTTP message with the provided encoding.
Operations on the bodies of HTTP messages
withDecodedBody :: (HasHeaders (r String), HasHeaders (r ByteString), HasBody r) => (String -> String) -> r ByteString -> Either EncodingError (r ByteString) Source
Allows to lift a transformation function operating on decoded (UTF-8) bodies to bodies of requests with encoded (and compressed) bodies.
withDecodedBodyM :: (Monad m, HasHeaders (r String), HasHeaders (r ByteString), HasBody r) => (String -> m String) -> r ByteString -> m (Either EncodingError (r ByteString)) Source
A monadic version of withDecodeBody
decodeBody :: (HasHeaders (r ByteString), HasBody r) => r ByteString -> Either EncodingError DecodingResult Source
Decodes and decompresses the response or request body using the information in the headers and content and possibly returns the body in UTF8
encodeBody :: EncodingName -> ContentEncoding -> String -> Either EncodingError ByteString Source
Takes a haskell UTF8-encoded string and produces a stream, encoded and compressed
Types
data DecodingResult Source
The result of decoding a message body