diff options
author | Sigbjorn Finne <sigbjorn.finne@gmail.com> | 2008-11-09 10:13:22 -0800 |
---|---|---|
committer | Sigbjorn Finne <sigbjorn.finne@gmail.com> | 2008-11-09 10:13:22 -0800 |
commit | 89c17335e3d35bd96dc4430329a18c36209a9e66 (patch) | |
tree | 4f54461bdc903d8169aef3f7294a1063ada9a051 /Codec/MIME/Type.hs | |
parent | 48270df4b7c981be0fa41a80916011fade98c0d3 (diff) |
MIMEValue: include extra header field + toggle to control inclusion of content-type when emitting its type; added nullMIMEValue for easier construction of MIMEValues; upped version to 0.3.0
Diffstat (limited to 'Codec/MIME/Type.hs')
-rw-r--r-- | Codec/MIME/Type.hs | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/Codec/MIME/Type.hs b/Codec/MIME/Type.hs index 8d9830a..ab16ab7 100644 --- a/Codec/MIME/Type.hs +++ b/Codec/MIME/Type.hs @@ -1,6 +1,6 @@ {- | - Module : MIME.Type + Module : Codec.MIME.Type Copyright : (c) 2006-2008, Galois Inc. - License : BSD3 @@ -21,13 +21,19 @@ data Type , mimeParams :: [(String,String)] } deriving ( Show, Ord, Eq ) +nullType :: Type +nullType = Type + { mimeType = Text "plain" + , mimeParams = [] + } + showType :: Type -> String showType t = showMIMEType (mimeType t) ++ showMIMEParams (mimeParams t) showMIMEParams :: [(String,String)] -> String showMIMEParams ps = concatMap showP ps where - showP (a,b) = ';':a ++ '=':'"':b ++ "\"" + showP (a,b) = ';':' ':a ++ '=':'"':b ++ "\"" data MIMEType @@ -133,11 +139,22 @@ showMultipart m = type Content = String -data MIMEValue = MIMEValue { - mime_val_type :: Type, - mime_val_disp :: Maybe Disposition, - mime_val_content :: MIMEContent } - deriving ( Show, Eq ) +data MIMEValue = MIMEValue + { mime_val_type :: Type + , mime_val_disp :: Maybe Disposition + , mime_val_content :: MIMEContent + , mime_val_headers :: [(String,String)] + , mime_val_inc_type :: Bool + } deriving ( Show, Eq ) + +nullMIMEValue :: MIMEValue +nullMIMEValue = MIMEValue + { mime_val_type = nullType + , mime_val_disp = Nothing + , mime_val_content = Multi [] + , mime_val_headers = [] + , mime_val_inc_type = True + } data MIMEContent = Single Content |