X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=Network%2FHTTP%2FLucu%2FMIMEType%2FGuess.hs;h=39de37e07d68464b8029021f745e956fa236c036;hb=70bf5bd248aa426ca4e410b3fb9a0529354aedaf;hp=d94711ac624cdfa9878243b55f46b1dbca61b223;hpb=50805329b976eb90092504d4d181269f151fbb82;p=Lucu.git diff --git a/Network/HTTP/Lucu/MIMEType/Guess.hs b/Network/HTTP/Lucu/MIMEType/Guess.hs index d94711a..39de37e 100644 --- a/Network/HTTP/Lucu/MIMEType/Guess.hs +++ b/Network/HTTP/Lucu/MIMEType/Guess.hs @@ -1,3 +1,7 @@ +{-# LANGUAGE + UnboxedTuples + , UnicodeSyntax + #-} -- |MIME Type guessing by a file extension. This is a poor man's way -- of guessing MIME Types. It is simple and fast. -- @@ -21,7 +25,6 @@ import Network.HTTP.Lucu.MIMEType import Network.HTTP.Lucu.Parser import Network.HTTP.Lucu.Parser.Http import Network.HTTP.Lucu.Utils -import System.IO -- |'Data.Map.Map' from extension to MIME Type. type ExtMap = Map String MIMEType @@ -56,14 +59,14 @@ extMapP = do xs <- many (comment <|> validLine <|> emptyLine) where spc = oneOf " \t" - comment = do many spc - char '#' - many $ satisfy (/= '\n') - return Nothing + comment = many spc >> + char '#' >> + ( many $ satisfy (/= '\n') ) >> + return Nothing - validLine = do many spc + validLine = do _ <- many spc mime <- mimeTypeP - many spc + _ <- many spc exts <- sepBy token (many spc) return $ Just (mime, exts)