summaryrefslogtreecommitdiffstats
path: root/Codec/MIME/Parse.hs
diff options
context:
space:
mode:
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)