summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIavor S. Diatchki <diatchki@galois.com>2012-10-04 16:39:28 -0700
committerIavor S. Diatchki <diatchki@galois.com>2012-10-04 16:39:28 -0700
commit5c2f21e06ebc2c3be936efadfe92872fecd82db9 (patch)
treecd9f7e158488fdf2380efb97aa6dfe6abc8a9bd0
parentc97baa979878145c599c057d8bba01618c223178 (diff)
Disable `tracing` by default.
To re-enable, turn on tracing in the parser file.
-rw-r--r--Codec/MIME/Parse.hs14
-rw-r--r--mime.cabal2
2 files changed, 12 insertions, 4 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 =
diff --git a/mime.cabal b/mime.cabal
index 2b9bf9a..eb4cc56 100644
--- a/mime.cabal
+++ b/mime.cabal
@@ -1,5 +1,5 @@
name: mime
-version: 0.3.3.2
+version: 0.3.4
synopsis: Working with MIME types.
description: Working with MIME types.
category: Codec