Network.Multipart

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

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
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 :: Monad m => String -> m ContentType
- getContentType :: Monad m => Headers -> m ContentType
- getContentTransferEncoding :: Monad m => Headers -> m ContentTransferEncoding
- getContentDisposition :: Monad m => Headers -> m ContentDisposition

# Multi-part messages

data MultiPart #

Constructors

MultiPart [BodyPart] |

Instances

Eq MultiPart # |
Methods (==) :: MultiPart -> MultiPart -> Bool # (/=) :: MultiPart -> MultiPart -> Bool #
Ord MultiPart # |
Methods compare :: MultiPart -> MultiPart -> Ordering # (<) :: MultiPart -> MultiPart -> Bool # (<=) :: MultiPart -> MultiPart -> Bool # (>) :: MultiPart -> MultiPart -> Bool # (>=) :: MultiPart -> MultiPart -> Bool # max :: MultiPart -> MultiPart -> MultiPart # min :: MultiPart -> MultiPart -> MultiPart #
Show MultiPart # |
Methods showsPrec :: Int -> MultiPart -> ShowS # show :: MultiPart -> String # showList :: [MultiPart] -> ShowS #

data BodyPart #

Constructors

BodyPart Headers ByteString |

Instances

Eq BodyPart # |
Methods (==) :: BodyPart -> BodyPart -> Bool # (/=) :: BodyPart -> BodyPart -> Bool #
Ord BodyPart # |
Methods compare :: BodyPart -> BodyPart -> Ordering # (<) :: BodyPart -> BodyPart -> Bool # (<=) :: BodyPart -> BodyPart -> Bool # (>) :: BodyPart -> BodyPart -> Bool # (>=) :: BodyPart -> BodyPart -> Bool # max :: BodyPart -> BodyPart -> BodyPart # min :: BodyPart -> BodyPart -> BodyPart #
Show BodyPart # |
Methods showsPrec :: Int -> BodyPart -> ShowS # show :: BodyPart -> String # showList :: [BodyPart] -> ShowS #

parseMultipartBody #

Arguments

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

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

hGetMultipartBody #

Arguments

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

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

showMultipartBody :: String -> MultiPart -> ByteString #

# Headers

type Headers = [(HeaderName, String)] #

HTTP headers.

newtype HeaderName #

A string with case insensitive equality and comparisons.

Constructors

HeaderName String |

Instances

Eq HeaderName # |
Methods (==) :: HeaderName -> HeaderName -> Bool # (/=) :: HeaderName -> HeaderName -> Bool #
Ord HeaderName # |
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 # |
Methods showsPrec :: Int -> HeaderName -> ShowS # show :: HeaderName -> String # showList :: [HeaderName] -> ShowS #

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 # |
Methods (==) :: ContentType -> ContentType -> Bool # (/=) :: ContentType -> ContentType -> Bool #
Ord ContentType # |
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 # |
Methods readsPrec :: Int -> ReadS ContentType # readList :: ReadS [ContentType] # readPrec :: ReadPrec ContentType # readListPrec :: ReadPrec [ContentType] #
Show ContentType # |
Methods showsPrec :: Int -> ContentType -> ShowS # show :: ContentType -> String # showList :: [ContentType] -> ShowS #
HeaderValue ContentType # |
Methods parseHeaderValue :: Parser ContentType # prettyHeaderValue :: ContentType -> String #

data ContentTransferEncoding #

Constructors

ContentTransferEncoding String |

Instances

Eq ContentTransferEncoding # |
Methods (==) :: ContentTransferEncoding -> ContentTransferEncoding -> Bool # (/=) :: ContentTransferEncoding -> ContentTransferEncoding -> Bool #
Ord ContentTransferEncoding # |
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 # |
Methods readsPrec :: Int -> ReadS ContentTransferEncoding # readList :: ReadS [ContentTransferEncoding] # readPrec :: ReadPrec ContentTransferEncoding # readListPrec :: ReadPrec [ContentTransferEncoding] #
Show ContentTransferEncoding # |
Methods showsPrec :: Int -> ContentTransferEncoding -> ShowS # show :: ContentTransferEncoding -> String # showList :: [ContentTransferEncoding] -> ShowS #
HeaderValue ContentTransferEncoding # |
Methods parseHeaderValue :: Parser ContentTransferEncoding # prettyHeaderValue :: ContentTransferEncoding -> String #

data ContentDisposition #

Constructors

ContentDisposition String [(String, String)] |

Instances

Eq ContentDisposition # |
Methods (==) :: ContentDisposition -> ContentDisposition -> Bool # (/=) :: ContentDisposition -> ContentDisposition -> Bool #
Ord ContentDisposition # |
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 # |
Methods readsPrec :: Int -> ReadS ContentDisposition # readList :: ReadS [ContentDisposition] # readPrec :: ReadPrec ContentDisposition # readListPrec :: ReadPrec [ContentDisposition] #
Show ContentDisposition # |
Methods showsPrec :: Int -> ContentDisposition -> ShowS # show :: ContentDisposition -> String # showList :: [ContentDisposition] -> ShowS #
HeaderValue ContentDisposition # |
Methods parseHeaderValue :: Parser ContentDisposition # prettyHeaderValue :: ContentDisposition -> String #

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.

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

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

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