From 89c17335e3d35bd96dc4430329a18c36209a9e66 Mon Sep 17 00:00:00 2001 From: Sigbjorn Finne Date: Sun, 9 Nov 2008 10:13:22 -0800 Subject: 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 --- Codec/MIME/Parse.hs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'Codec/MIME/Parse.hs') 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) -- cgit v1.2.3