Network.Multipart.Header

multipart-0.1.2: HTTP multipart split out of the cgi package

Copyright | (c) Peter Thiemann 2001,2002 (c) Bjorn Bringert 2005-2006
License | BSD-style
Maintainer | Anders Kaseorg <andersk@mit.edu>
Stability | experimental
Portability | non-portable
Safe Haskell | Safe
Language | Haskell2010

Network.Multipart.Header

Contents

- Headers
- Content-type
- Content-transfer-encoding
- Content-disposition
- Utilities

Description

Parsing of HTTP headers (name, value pairs) Partly based on code from WASHMail.

Synopsis

- type Headers = [(HeaderName, String)]
- newtype HeaderName = HeaderName String
- class HeaderValue a where
  - parseHeaderValue :: Parser a
  - prettyHeaderValue :: a -> String
- pHeaders :: Parser Headers
- data ContentType = ContentType {
  - ctType :: String
  - ctSubtype :: String
  - ctParameters :: [(String, String)]
  }
- getContentType :: Monad m => Headers -> m ContentType
- parseContentType :: Monad m => String -> m ContentType
- showContentType :: ContentType -> String
- data ContentTransferEncoding = ContentTransferEncoding String
- getContentTransferEncoding :: Monad m => Headers -> m ContentTransferEncoding
- data ContentDisposition = ContentDisposition String [(String, String)]
- getContentDisposition :: Monad m => Headers -> m ContentDisposition
- parseM :: Monad m => Parser a -> SourceName -> String -> m a
- caseInsensitiveEq :: String -> String -> Bool
- caseInsensitiveCompare :: String -> String -> Ordering
- lexeme :: Parser a -> Parser a
- ws1 :: Parser Char
- p_token :: Parser String

# Headers

type Headers = [(HeaderName, String)]

HTTP headers.

newtype HeaderName

A string with case insensitive equality and comparisons.

Constructors

HeaderName String |

Instances

Eq HeaderName |
Ord HeaderName |
Show HeaderName |

class HeaderValue a where

Methods

parseHeaderValue :: Parser a

prettyHeaderValue :: a -> String

Instances

HeaderValue ContentDisposition |
HeaderValue ContentTransferEncoding |
HeaderValue ContentType |

pHeaders :: Parser Headers

# Content-type

data ContentType

A MIME media type value. The `Show` instance is derived automatically. Use `showContentType` to obtain the standard string representation. See http://www.ietf.org/rfc/rfc2046.txt for more information about MIME media types.

Constructors

ContentType |
Fields ctType :: String The top-level media type, the general type of the data. Common examples are "text", "image", "audio", "video", "multipart", and "application". ctSubtype :: String The media subtype, the specific data format. Examples include "plain", "html", "jpeg", "form-data", etc. ctParameters :: [(String, String)] Media type parameters. On common example is the charset parameter for the "text" top-level type, e.g. `("charset","ISO-8859-1")`.

Instances

Eq ContentType |
Ord ContentType |
Read ContentType |
Show ContentType |
HeaderValue ContentType |

getContentType :: Monad m => Headers -> m ContentType

parseContentType :: Monad m => String -> m ContentType

Parse the standard representation of a content-type. If the input cannot be parsed, this function calls `fail` with a (hopefully) informative error message.

showContentType :: ContentType -> String

# Content-transfer-encoding

data ContentTransferEncoding

Constructors

ContentTransferEncoding String |

Instances

Eq ContentTransferEncoding |
Ord ContentTransferEncoding |
Read ContentTransferEncoding |
Show ContentTransferEncoding |
HeaderValue ContentTransferEncoding |

getContentTransferEncoding :: Monad m => Headers -> m ContentTransferEncoding

# Content-disposition

data ContentDisposition

Constructors

ContentDisposition String [(String, String)] |

Instances

Eq ContentDisposition |
Ord ContentDisposition |
Read ContentDisposition |
Show ContentDisposition |
HeaderValue ContentDisposition |

getContentDisposition :: Monad m => Headers -> m ContentDisposition

# Utilities

parseM :: Monad m => Parser a -> SourceName -> String -> m a

caseInsensitiveEq :: String -> String -> Bool

caseInsensitiveCompare :: String -> String -> Ordering

lexeme :: Parser a -> Parser a

ws1 :: Parser Char

RFC 822 LWSP-char

p_token :: Parser String