web-encodings- Encapsulate multiple web encoding in a single package. (deprecated)

MaintainerMichael Snoyman <michael@snoyman.com>
Safe HaskellSafe-Infered




Various web encodings.


Simple encodings.

URL (percentage encoding)

encodeUrl :: StringLike a => a -> aSource

Encode all but unreserved characters with percentage encoding.

This function implicitly converts the given value to a UTF-8 bytestream.

decodeUrl :: StringLike s => s -> sSource

Decode percentage encoding. Assumes use of UTF-8 character encoding.

If there are any parse errors, this returns the original input. If you would like to be alerted more directly of errors, use decodeUrlFailure.

decodeUrlFailure :: (Failure DecodeUrlException m, StringLike s, Monad m) => s -> m sSource

Same as decodeUrl, but failures on either invalid percent or UTF8 encoding.

HTML (entity encoding)

encodeHtml :: StringLike s => s -> sSource

Escape special HTML characters.

decodeHtml :: StringLike s => s -> sSource

Decode HTML-encoded content into plain content.

Note: this does not support all HTML entities available. It also swallows all failures.


encodeJson :: StringLike s => s -> sSource

Perform JSON-encoding on a string. Does not wrap in quotation marks. Taken from json package by Sigbjorn Finne.

HTTP level encoding.

Query string- pairs of percentage encoding

encodeUrlPairs :: StringLike s => [(s, s)] -> sSource

Convert a list of key-values pairs into a query string. Does not include the question mark at the beginning.

decodeUrlPairs :: StringLike s => s -> [(s, s)]Source

Convert into key-value pairs. Strips the leading ? if necesary.

decodeUrlPairsFailure :: (StringLike s, Failure DecodeUrlException m, Monad m) => s -> m [(s, s)]Source

Convert into key-value pairs. Strips the leading ? if necesary. failures as necesary for invalid encodings.

Post parameters

data FileInfo s c Source

Information on an uploaded file.




fileName :: s
fileContentType :: s
fileContent :: c


(Eq s, Eq c) => Eq (FileInfo s c) 
(Show s, Show c) => Show (FileInfo s c) 



:: StringLike s 
=> String


-> s


-> ([(s, s)], [(s, FileInfo s s)]) 

Parse a multipart form into parameters and files.



:: StringLike s 
=> String

content type

-> String

content length

-> s

body of the post

-> ([(s, s)], [(s, FileInfo s s)]) 

Parse a post request. This function determines the correct decoding function to use.

Specific HTTP headers

decodeCookies :: StringLike s => s -> [(s, s)]Source

Deprecate alias for parseCookies.

parseCookies :: StringLike s => s -> [(s, s)]Source

Decode the value of an HTTP_COOKIE header into key/value pairs.

parseHttpAccept :: StringLike s => s -> [s]Source

Parse the HTTP accept string to determine supported content types.

Date/time encoding

formatW3 :: UTCTime -> StringSource

Format a UTCTime in W3 format; useful for setting cookies.

WAI-specific decodings

data Sink x y Source

A destination for data, the opposite of a Source.




sinkInit :: IO x
sinkAppend :: x -> ByteString -> IO x
sinkClose :: x -> IO y
sinkFinalize :: y -> IO ()