multipart 0.1.0.1 → 0.1.1
raw patch · 3 files changed
+63/−8 lines, 3 filesdep −MonadCatchIO-mtldep −MonadCatchIO-transformersdep −cginew-uploaderPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies removed: MonadCatchIO-mtl, MonadCatchIO-transformers, cgi
API changes (from Hackage documentation)
+ Network.Multipart: HeaderName :: String -> HeaderName
+ Network.Multipart: newtype HeaderName
+ Network.Multipart: type Headers = [(HeaderName, String)]
- Network.Multipart: data ContentType :: *
+ Network.Multipart: data ContentType
Files
- Network/Multipart.hs +1/−0
- Network/Multipart/Header.hs +61/−3
- multipart.cabal +1/−5
Network/Multipart.hs view
@@ -22,6 +22,7 @@ , parseMultipartBody, hGetMultipartBody , showMultipartBody -- * Headers+ , Headers , HeaderName(..) , ContentType(..), ContentTransferEncoding(..) , ContentDisposition(..) , parseContentType
Network/Multipart/Header.hs view
@@ -46,9 +46,7 @@ import Control.Monad import Data.Char import Data.List--import Network.CGI.Protocol-import Network.CGI+import Data.Monoid import Text.ParserCombinators.Parsec @@ -56,6 +54,19 @@ -- * Headers -- +-- | HTTP headers.+type Headers = [(HeaderName, String)]++-- | A string with case insensitive equality and comparisons.+newtype HeaderName = HeaderName String deriving (Show)++instance Eq HeaderName where+ HeaderName x == HeaderName y = map toLower x == map toLower y++instance Ord HeaderName where+ HeaderName x `compare` HeaderName y = map toLower x `compare` map toLower y++ class HeaderValue a where parseHeaderValue :: Parser a prettyHeaderValue :: a -> String@@ -120,6 +131,44 @@ p_value <- litStr <|> p_token return (map toLower p_name, p_value) +--+-- * Content type+--++-- | 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.+data ContentType =+ ContentType {+ -- | The top-level media type, the general type+ -- of the data. Common examples are+ -- \"text\", \"image\", \"audio\", \"video\",+ -- \"multipart\", and \"application\".+ ctType :: String,+ -- | The media subtype, the specific data format.+ -- Examples include \"plain\", \"html\",+ -- \"jpeg\", \"form-data\", etc.+ ctSubtype :: String,+ -- | Media type parameters. On common example is+ -- the charset parameter for the \"text\"+ -- top-level type, e.g. @(\"charset\",\"ISO-8859-1\")@.+ ctParameters :: [(String, String)]+ }+ deriving (Show, Read)++instance Eq ContentType where+ x == y = ctType x `caseInsensitiveEq` ctType y+ && ctSubtype x `caseInsensitiveEq` ctSubtype y+ && ctParameters x == ctParameters y++instance Ord ContentType where+ x `compare` y = mconcat [ctType x `caseInsensitiveCompare` ctType y,+ ctSubtype x `caseInsensitiveCompare` ctSubtype y,+ ctParameters x `compare` ctParameters y]+ instance HeaderValue ContentType where parseHeaderValue = do _ <- many ws1@@ -130,6 +179,15 @@ return $ ContentType (map toLower c_type) (map toLower c_subtype) c_parameters prettyHeaderValue (ContentType x y ps) = x ++ "/" ++ y ++ showParameters ps ++-- | Parse the standard representation of a content-type.+-- If the input cannot be parsed, this function calls+-- 'fail' with a (hopefully) informative error message.+parseContentType :: Monad m => String -> m ContentType+parseContentType = parseM parseHeaderValue "Content-type"++showContentType :: ContentType -> String+showContentType = prettyHeaderValue getContentType :: Monad m => Headers -> m ContentType getContentType = getHeaderValue "content-type"
multipart.cabal view
@@ -1,5 +1,5 @@ name: multipart-version: 0.1.0.1+version: 0.1.1 synopsis: A partial fork of the cgi package exposing the multipart module description: A partial fork of the cgi package exposing the multipart module copyright: Bjorn Bringert, Andy Gill, Anders Kaseorg, Ian Lynagh, Erik Meijer, Sven Panne, Jeremy Shaw@@ -23,9 +23,5 @@ other-modules: Network.Multipart.Header build-depends: base >= 3 && < 5- -- Reject versions depending on monads-tf- , MonadCatchIO-mtl == 0.3.0.5- , MonadCatchIO-transformers == 0.3.0.* , bytestring- , cgi >= 3001.1.8 && < 3001.1.9 , parsec >= 2.0