http-encodings-0.9.1: A library for encoding and decoding bodies of HTTP messages

Safe HaskellNone

Network.HTTP.Encoding

Contents

Description

Encoding and decoding of bodies and complete HTTP messages. See package jespresso for an example of usage.

Synopsis

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 DecodingResultSource

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 ByteStringSource

Takes a haskell UTF8-encoded string and produces a stream, encoded and compressed

Types

class HasBody a whereSource

Methods

getBody :: a b -> bSource

setBody :: c -> a b -> a cSource

data EncodingError Source

Encoding/Decoding error message

Instances

data DecodingResult Source

The result of decoding a message body