diff options
author | Iavor S. Diatchki <diatchki@galois.com> | 2012-10-04 16:39:28 -0700 |
---|---|---|
committer | Iavor S. Diatchki <diatchki@galois.com> | 2012-10-04 16:39:28 -0700 |
commit | 5c2f21e06ebc2c3be936efadfe92872fecd82db9 (patch) | |
tree | cd9f7e158488fdf2380efb97aa6dfe6abc8a9bd0 /Codec/MIME | |
parent | c97baa979878145c599c057d8bba01618c223178 (diff) |
Disable `tracing` by default.
To re-enable, turn on tracing in the parser file.
Diffstat (limited to 'Codec/MIME')
-rw-r--r-- | Codec/MIME/Parse.hs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/Codec/MIME/Parse.hs b/Codec/MIME/Parse.hs index 6108441..dfe2115 100644 --- a/Codec/MIME/Parse.hs +++ b/Codec/MIME/Parse.hs @@ -30,6 +30,14 @@ import Data.Maybe import Data.List import Debug.Trace ( trace ) +enableTrace :: Bool +enableTrace = False + +doTrace :: String -> b -> b +doTrace | enableTrace = trace + | otherwise = \_ x -> x + + parseMIMEBody :: [(String,String)] -> String -> MIMEValue parseMIMEBody headers_in body = result { mime_val_headers = headers } where @@ -117,7 +125,7 @@ parseHeaders str = parseMultipart :: Type -> String -> (MIMEValue, String) parseMultipart mty body = case lookupField "boundary" (mimeParams mty) of - Nothing -> trace ("Multipart mime type, " ++ showType mty ++ + Nothing -> doTrace ("Multipart mime type, " ++ showType mty ++ ", has no required boundary parameter. Defaulting to text/plain") $ (nullMIMEValue{ mime_val_type = defaultType , mime_val_disp = Nothing @@ -169,7 +177,7 @@ parseContentType str = Just Type { mimeType = toType maj as , mimeParams = parseParams (dropWhile isHSpace bs) } - _ -> trace ("unable to parse content-type: " ++ show str) $ Nothing + _ -> doTrace ("unable to parse content-type: " ++ show str) $ Nothing where toType a b = case lookupField (map toLower a) mediaTypes of Just ctor -> ctor b @@ -191,7 +199,7 @@ parseParams (';':xs) = where nm = map toLower nm_raw -parseParams cs = trace ("Codec.MIME.Parse.parseParams: curious param value -- " ++ show cs) [] +parseParams cs = doTrace ("Codec.MIME.Parse.parseParams: curious param value -- " ++ show cs) [] mediaTypes :: [(String, String -> MIMEType)] mediaTypes = |