From c2506144edbe41f896a54c5cfd7c829f35ec120d Mon Sep 17 00:00:00 2001 From: tv <tv@shackspace.de> Date: Wed, 4 Mar 2015 20:55:13 +0100 Subject: mime: use CI --- Codec/MIME/Type.hs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'Codec/MIME/Type.hs') diff --git a/Codec/MIME/Type.hs b/Codec/MIME/Type.hs index 2ae9abd..72ec94f 100644 --- a/Codec/MIME/Type.hs +++ b/Codec/MIME/Type.hs @@ -15,10 +15,12 @@ -------------------------------------------------------------------- module Codec.MIME.Type where +import Data.CaseInsensitive (CI) +import qualified Data.CaseInsensitive as CI import qualified Data.Text as T import Data.Monoid ((<>)) -data MIMEParam = MIMEParam { paramName :: T.Text +data MIMEParam = MIMEParam { paramName :: CI T.Text , paramValue :: T.Text } deriving (Show, Ord, Eq) @@ -40,7 +42,7 @@ showType t = showMIMEType (mimeType t) <> showMIMEParams (mimeParams t) showMIMEParams :: [MIMEParam] -> T.Text showMIMEParams ps = T.concat $ map showP ps where - showP (MIMEParam a b) = "; " <> a <> "=\"" <> b <> "\"" + showP (MIMEParam k v) = "; " <> CI.original k <> "=\"" <> v <> "\"" data MIMEType @@ -52,7 +54,7 @@ data MIMEType | Multipart Multipart | Text TextType | Video SubType - | Other {otherType :: T.Text, otherSubType :: SubType} + | Other {otherType :: CI T.Text, otherSubType :: SubType} deriving ( Show, Ord, Eq ) showMIMEType :: MIMEType -> T.Text @@ -66,7 +68,7 @@ showMIMEType t = Multipart s -> "multipart/"<>showMultipart s Text s -> "text/"<>s Video s -> "video/"<>s - Other a b -> a <> "/" <> b + Other a b -> CI.original a <> "/" <> b -- | a (type, subtype) MIME pair. data MIMEPair @@ -183,5 +185,5 @@ data DispParam | ModDate T.Text | ReadDate T.Text | Size T.Text - | OtherParam T.Text T.Text + | OtherParam (CI T.Text) T.Text deriving ( Show, Eq) -- cgit v1.2.3