multipart-0.2.1: Parsers for the HTTP multipart format

Copyright | (c) Peter Thiemann 20012002 (c) Bjorn Bringert 2005-2006
License | BSD-style
Maintainer | Anders Kaseorg <andersk@mit.edu>
Stability | experimental
Portability | non-portable
Safe Haskell | Safe-Inferred
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 :: MonadFail m => Headers -> m ContentType
- parseContentType :: MonadFail m => String -> m ContentType
- showContentType :: ContentType -> String
- data ContentTransferEncoding = ContentTransferEncoding String
- getContentTransferEncoding :: MonadFail m => Headers -> m ContentTransferEncoding
- data ContentDisposition = ContentDisposition String [(String, String)]
- getContentDisposition :: MonadFail m => Headers -> m ContentDisposition
- parseM :: MonadFail 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

Instances details

Eq HeaderName # |
Instance details Defined in Network.Multipart.Header Methods (==) :: HeaderName -> HeaderName -> Bool # (/=) :: HeaderName -> HeaderName -> Bool #
Ord HeaderName # |
Instance details Defined in Network.Multipart.Header Methods compare :: HeaderName -> HeaderName -> Ordering # (<) :: HeaderName -> HeaderName -> Bool # (<=) :: HeaderName -> HeaderName -> Bool # (>) :: HeaderName -> HeaderName -> Bool # (>=) :: HeaderName -> HeaderName -> Bool # max :: HeaderName -> HeaderName -> HeaderName # min :: HeaderName -> HeaderName -> HeaderName #
Show HeaderName # |
Instance details Defined in Network.Multipart.Header Methods showsPrec :: Int -> HeaderName -> ShowS # show :: HeaderName -> String # showList :: [HeaderName] -> ShowS #

class HeaderValue a where #

Methods

parseHeaderValue :: Parser a #

prettyHeaderValue :: a -> String #

#### Instances

Instances details

HeaderValue ContentDisposition # |
Instance details Defined in Network.Multipart.Header Methods parseHeaderValue :: Parser ContentDisposition # prettyHeaderValue :: ContentDisposition -> String #
HeaderValue ContentTransferEncoding # |
Instance details Defined in Network.Multipart.Header Methods parseHeaderValue :: Parser ContentTransferEncoding # prettyHeaderValue :: ContentTransferEncoding -> String #
HeaderValue ContentType # |
Instance details Defined in Network.Multipart.Header Methods parseHeaderValue :: Parser ContentType # prettyHeaderValue :: ContentType -> String #

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

Instances details

Eq ContentType # |
Instance details Defined in Network.Multipart.Header Methods (==) :: ContentType -> ContentType -> Bool # (/=) :: ContentType -> ContentType -> Bool #
Ord ContentType # |
Instance details Defined in Network.Multipart.Header Methods compare :: ContentType -> ContentType -> Ordering # (<) :: ContentType -> ContentType -> Bool # (<=) :: ContentType -> ContentType -> Bool # (>) :: ContentType -> ContentType -> Bool # (>=) :: ContentType -> ContentType -> Bool # max :: ContentType -> ContentType -> ContentType # min :: ContentType -> ContentType -> ContentType #
Read ContentType # |
Instance details Defined in Network.Multipart.Header Methods readsPrec :: Int -> ReadS ContentType # readList :: ReadS [ContentType] # readPrec :: ReadPrec ContentType # readListPrec :: ReadPrec [ContentType] #
Show ContentType # |
Instance details Defined in Network.Multipart.Header Methods showsPrec :: Int -> ContentType -> ShowS # show :: ContentType -> String # showList :: [ContentType] -> ShowS #
HeaderValue ContentType # |
Instance details Defined in Network.Multipart.Header Methods parseHeaderValue :: Parser ContentType # prettyHeaderValue :: ContentType -> String #

getContentType :: MonadFail m => Headers -> m ContentType #

parseContentType :: MonadFail 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

Instances details

Eq ContentTransferEncoding # |
Instance details Defined in Network.Multipart.Header Methods (==) :: ContentTransferEncoding -> ContentTransferEncoding -> Bool # (/=) :: ContentTransferEncoding -> ContentTransferEncoding -> Bool #
Ord ContentTransferEncoding # |
Instance details Defined in Network.Multipart.Header Methods compare :: ContentTransferEncoding -> ContentTransferEncoding -> Ordering # (<) :: ContentTransferEncoding -> ContentTransferEncoding -> Bool # (<=) :: ContentTransferEncoding -> ContentTransferEncoding -> Bool # (>) :: ContentTransferEncoding -> ContentTransferEncoding -> Bool # (>=) :: ContentTransferEncoding -> ContentTransferEncoding -> Bool # max :: ContentTransferEncoding -> ContentTransferEncoding -> ContentTransferEncoding # min :: ContentTransferEncoding -> ContentTransferEncoding -> ContentTransferEncoding #
Read ContentTransferEncoding # |
Instance details Defined in Network.Multipart.Header Methods readsPrec :: Int -> ReadS ContentTransferEncoding # readList :: ReadS [ContentTransferEncoding] # readPrec :: ReadPrec ContentTransferEncoding # readListPrec :: ReadPrec [ContentTransferEncoding] #
Show ContentTransferEncoding # |
Instance details Defined in Network.Multipart.Header Methods showsPrec :: Int -> ContentTransferEncoding -> ShowS # show :: ContentTransferEncoding -> String # showList :: [ContentTransferEncoding] -> ShowS #
HeaderValue ContentTransferEncoding # |
Instance details Defined in Network.Multipart.Header Methods parseHeaderValue :: Parser ContentTransferEncoding # prettyHeaderValue :: ContentTransferEncoding -> String #

getContentTransferEncoding :: MonadFail m => Headers -> m ContentTransferEncoding #

# Content-disposition

data ContentDisposition #

Constructors

ContentDisposition String [(String, String)] |

#### Instances

Instances details

Eq ContentDisposition # |
Instance details Defined in Network.Multipart.Header Methods (==) :: ContentDisposition -> ContentDisposition -> Bool # (/=) :: ContentDisposition -> ContentDisposition -> Bool #
Ord ContentDisposition # |
Instance details Defined in Network.Multipart.Header Methods compare :: ContentDisposition -> ContentDisposition -> Ordering # (<) :: ContentDisposition -> ContentDisposition -> Bool # (<=) :: ContentDisposition -> ContentDisposition -> Bool # (>) :: ContentDisposition -> ContentDisposition -> Bool # (>=) :: ContentDisposition -> ContentDisposition -> Bool # max :: ContentDisposition -> ContentDisposition -> ContentDisposition # min :: ContentDisposition -> ContentDisposition -> ContentDisposition #
Read ContentDisposition # |
Instance details Defined in Network.Multipart.Header Methods readsPrec :: Int -> ReadS ContentDisposition # readList :: ReadS [ContentDisposition] # readPrec :: ReadPrec ContentDisposition # readListPrec :: ReadPrec [ContentDisposition] #
Show ContentDisposition # |
Instance details Defined in Network.Multipart.Header Methods showsPrec :: Int -> ContentDisposition -> ShowS # show :: ContentDisposition -> String # showList :: [ContentDisposition] -> ShowS #
HeaderValue ContentDisposition # |
Instance details Defined in Network.Multipart.Header Methods parseHeaderValue :: Parser ContentDisposition # prettyHeaderValue :: ContentDisposition -> String #

getContentDisposition :: MonadFail m => Headers -> m ContentDisposition #

# Utilities

parseM :: MonadFail 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 #