X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=Lucu.git;a=blobdiff_plain;f=Network%2FHTTP%2FLucu%2FMIMEType%2FGuess.hs;h=65bf3a607cc4b8306d5d7114485fb7452817ffe1;hp=93a1479837fb4c98f015faa163f48430d9778dd3;hb=858129cb755aa09da2b7bd758efb8519f2c89103;hpb=5b255535f2c7d2a6d4622ad164b31e63746b906e diff --git a/Network/HTTP/Lucu/MIMEType/Guess.hs b/Network/HTTP/Lucu/MIMEType/Guess.hs index 93a1479..65bf3a6 100644 --- a/Network/HTTP/Lucu/MIMEType/Guess.hs +++ b/Network/HTTP/Lucu/MIMEType/Guess.hs @@ -30,14 +30,16 @@ type ExtMap = Map String MIMEType -- |Guess the MIME Type of file. guessTypeByFileName :: ExtMap -> FilePath -> Maybe MIMEType guessTypeByFileName extMap fpath - = let ext = last $ splitBy (== '.') fpath + = extMap `seq` fpath `seq` + let ext = last $ splitBy (== '.') fpath in M.lookup ext extMap >>= return -- |Read an Apache mime.types and parse it. parseExtMapFile :: FilePath -> IO ExtMap parseExtMapFile fpath - = do file <- B.readFile fpath + = fpath `seq` + do file <- B.readFile fpath case parse (allowEOF extMapP) file of (Success xs, _) -> return $ compile xs (_, input') -> let near = B.unpack $ B.take 100 input'