summaryrefslogtreecommitdiffstats
path: root/Codec/MIME/Parse.hs
diff options
context:
space:
mode:
authorSigbjorn Finne <sigbjorn.finne@gmail.com>2008-11-09 10:13:22 -0800
committerSigbjorn Finne <sigbjorn.finne@gmail.com>2008-11-09 10:13:22 -0800
commit89c17335e3d35bd96dc4430329a18c36209a9e66 (patch)
tree4f54461bdc903d8169aef3f7294a1063ada9a051 /Codec/MIME/Parse.hs
parent48270df4b7c981be0fa41a80916011fade98c0d3 (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/Parse.hs')
-rw-r--r--Codec/MIME/Parse.hs17
1 files changed, 13 insertions, 4 deletions
diff --git a/Codec/MIME/Parse.hs b/Codec/MIME/Parse.hs
index 629a0cf..07bdb46 100644
--- a/Codec/MIME/Parse.hs
+++ b/Codec/MIME/Parse.hs
@@ -26,8 +26,11 @@ parseMIMEBody headers_in body =
case mimeType mty of
Multipart{} -> fst (parseMultipart mty body)
Message{} -> fst (parseMultipart mty body)
- _ -> MIMEValue mty (parseContentDisp headers)
- (Single (processBody headers body))
+ _ -> nullMIMEValue
+ { mime_val_type = mty
+ , mime_val_disp = parseContentDisp headers
+ , mime_val_content = Single (processBody headers body)
+ }
where headers = [ (map toLower k,v) | (k,v) <- headers_in ]
mty = fromMaybe defaultType
@@ -102,8 +105,14 @@ parseMultipart mty body =
case lookupField "boundary" (mimeParams mty) of
Nothing -> trace ("Multipart mime type, " ++ showType mty ++
", has no required boundary parameter. Defaulting to text/plain") $
- (MIMEValue defaultType Nothing (Single body), "")
- Just bnd -> (MIMEValue mty Nothing (Multi vals), rs)
+ (nullMIMEValue{ mime_val_type = defaultType
+ , mime_val_disp = Nothing
+ , mime_val_content = Single body
+ }, "")
+ Just bnd -> (nullMIMEValue { mime_val_type = mty
+ , mime_val_disp = Nothing
+ , mime_val_content = Multi vals
+ }, rs)
where (vals,rs) = splitMulti bnd body
splitMulti :: String -> String -> ([MIMEValue], String)