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 | None
Language | Haskell2010

Network.Multipart

Contents

- Multi-part messages
- Headers

Description

Parsing of the multipart format from RFC2046. Partly based on code from WASHMail.

Synopsis

- data MultiPart = MultiPart [BodyPart]
- data BodyPart = BodyPart Headers ByteString
- parseMultipartBody :: String -> ByteString -> MultiPart
- hGetMultipartBody :: String -> Handle -> IO MultiPart
- showMultipartBody :: String -> MultiPart -> ByteString
- type Headers = [(HeaderName, String)]
- newtype HeaderName = HeaderName String
- data ContentType = ContentType {
  - ctType :: String
  - ctSubtype :: String
  - ctParameters :: [(String, String)]
  }
- data ContentTransferEncoding = ContentTransferEncoding String
- data ContentDisposition = ContentDisposition String [(String, String)]
- parseContentType :: MonadFail m => String -> m ContentType
- getContentType :: MonadFail m => Headers -> m ContentType
- getContentTransferEncoding :: MonadFail m => Headers -> m ContentTransferEncoding
- getContentDisposition :: MonadFail m => Headers -> m ContentDisposition

# Multi-part messages

data MultiPart Source #

Constructors

MultiPart [BodyPart] |

#### Instances

Instances details

Show MultiPart Source # |
Instance details Defined in Network.Multipart Methods showsPrec :: Int -> MultiPart -> ShowS Source # show :: MultiPart -> String Source # showList :: [MultiPart] -> ShowS Source #
Eq MultiPart Source # |
Instance details Defined in Network.Multipart Methods (==) :: MultiPart -> MultiPart -> Bool Source # (/=) :: MultiPart -> MultiPart -> Bool Source #
Ord MultiPart Source # |

Instance details

Defined in Network.Multipart

Methods

compare :: MultiPart -> MultiPart -> Ordering Source #

(<) :: MultiPart -> MultiPart -> Bool Source #

(<=) :: MultiPart -> MultiPart -> Bool Source #

(>) :: MultiPart -> MultiPart -> Bool Source #

(>=) :: MultiPart -> MultiPart -> Bool Source #

max :: MultiPart -> MultiPart -> MultiPart Source #

min :: MultiPart -> MultiPart -> MultiPart Source #

data BodyPart Source #

Constructors

BodyPart Headers ByteString |

#### Instances

Instances details

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

parseMultipartBody Source #

Arguments

:: String | Boundary
-> ByteString |
-> MultiPart |

Read a multi-part message from a `ByteString`.

hGetMultipartBody Source #

Arguments

:: String | Boundary
-> Handle |
-> IO MultiPart |

Read a multi-part message from a `Handle`. Fails on parse errors.

showMultipartBody :: String -> MultiPart -> ByteString Source #

# Headers

type Headers = [(HeaderName, String)] Source #

HTTP headers.

newtype HeaderName Source #

A string with case insensitive equality and comparisons.

Constructors

HeaderName String |

#### Instances

Instances details

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

Instance details

Defined in Network.Multipart.Header

Methods

compare :: HeaderName -> HeaderName -> Ordering Source #

(<) :: HeaderName -> HeaderName -> Bool Source #

(<=) :: HeaderName -> HeaderName -> Bool Source #

(>) :: HeaderName -> HeaderName -> Bool Source #

(>=) :: HeaderName -> HeaderName -> Bool Source #

max :: HeaderName -> HeaderName -> HeaderName Source #

min :: HeaderName -> HeaderName -> HeaderName Source #

data ContentType Source #

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

Read ContentType Source # |
Instance details Defined in Network.Multipart.Header Methods readsPrec :: Int -> ReadS ContentType Source # readList :: ReadS [ContentType] Source # readPrec :: ReadPrec ContentType Source # readListPrec :: ReadPrec [ContentType] Source #
Show ContentType Source # |
Instance details Defined in Network.Multipart.Header Methods showsPrec :: Int -> ContentType -> ShowS Source # show :: ContentType -> String Source # showList :: [ContentType] -> ShowS Source #
Eq ContentType Source # |
Instance details Defined in Network.Multipart.Header Methods (==) :: ContentType -> ContentType -> Bool Source # (/=) :: ContentType -> ContentType -> Bool Source #
Ord ContentType Source # |

Instance details

Defined in Network.Multipart.Header

Methods

compare :: ContentType -> ContentType -> Ordering Source #

(<) :: ContentType -> ContentType -> Bool Source #

(<=) :: ContentType -> ContentType -> Bool Source #

(>) :: ContentType -> ContentType -> Bool Source #

(>=) :: ContentType -> ContentType -> Bool Source #

max :: ContentType -> ContentType -> ContentType Source #

min :: ContentType -> ContentType -> ContentType Source #

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

data ContentTransferEncoding Source #

Constructors

ContentTransferEncoding String |

#### Instances

Instances details

Read ContentTransferEncoding Source # |
Instance details Defined in Network.Multipart.Header Methods readsPrec :: Int -> ReadS ContentTransferEncoding Source # readList :: ReadS [ContentTransferEncoding] Source # readPrec :: ReadPrec ContentTransferEncoding Source # readListPrec :: ReadPrec [ContentTransferEncoding] Source #
Show ContentTransferEncoding Source # |
Instance details Defined in Network.Multipart.Header Methods showsPrec :: Int -> ContentTransferEncoding -> ShowS Source # show :: ContentTransferEncoding -> String Source # showList :: [ContentTransferEncoding] -> ShowS Source #
Eq ContentTransferEncoding Source # |
Instance details Defined in Network.Multipart.Header Methods (==) :: ContentTransferEncoding -> ContentTransferEncoding -> Bool Source # (/=) :: ContentTransferEncoding -> ContentTransferEncoding -> Bool Source #
Ord ContentTransferEncoding Source # |

Instance details

Defined in Network.Multipart.Header

Methods

compare :: ContentTransferEncoding -> ContentTransferEncoding -> Ordering Source #

(<) :: ContentTransferEncoding -> ContentTransferEncoding -> Bool Source #

(<=) :: ContentTransferEncoding -> ContentTransferEncoding -> Bool Source #

(>) :: ContentTransferEncoding -> ContentTransferEncoding -> Bool Source #

(>=) :: ContentTransferEncoding -> ContentTransferEncoding -> Bool Source #

max :: ContentTransferEncoding -> ContentTransferEncoding -> ContentTransferEncoding Source #

min :: ContentTransferEncoding -> ContentTransferEncoding -> ContentTransferEncoding Source #

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

data ContentDisposition Source #

Constructors

ContentDisposition String [(String, String)] |

#### Instances

Instances details

Read ContentDisposition Source # |
Instance details Defined in Network.Multipart.Header Methods readsPrec :: Int -> ReadS ContentDisposition Source # readList :: ReadS [ContentDisposition] Source # readPrec :: ReadPrec ContentDisposition Source # readListPrec :: ReadPrec [ContentDisposition] Source #
Show ContentDisposition Source # |
Instance details Defined in Network.Multipart.Header Methods showsPrec :: Int -> ContentDisposition -> ShowS Source # show :: ContentDisposition -> String Source # showList :: [ContentDisposition] -> ShowS Source #
Eq ContentDisposition Source # |
Instance details Defined in Network.Multipart.Header Methods (==) :: ContentDisposition -> ContentDisposition -> Bool Source # (/=) :: ContentDisposition -> ContentDisposition -> Bool Source #
Ord ContentDisposition Source # |

Instance details

Defined in Network.Multipart.Header

Methods

compare :: ContentDisposition -> ContentDisposition -> Ordering Source #

(<) :: ContentDisposition -> ContentDisposition -> Bool Source #

(<=) :: ContentDisposition -> ContentDisposition -> Bool Source #

(>) :: ContentDisposition -> ContentDisposition -> Bool Source #

(>=) :: ContentDisposition -> ContentDisposition -> Bool Source #

max :: ContentDisposition -> ContentDisposition -> ContentDisposition Source #

min :: ContentDisposition -> ContentDisposition -> ContentDisposition Source #

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

parseContentType :: MonadFail m => String -> m ContentType Source #

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

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

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

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