module WASH.CGI.ContentType where
import Data.Char (toLower)
import Data.List (isSuffixOf)
guessContentType :: String -> String
guessContentType name = g (map toLower name)
where
g name
| ".eps" `isSuffixOf` name = "application/postscript"
| ".ps" `isSuffixOf` name = "application/postscript"
| ".ps.gz" `isSuffixOf` name = "application/postscript"
| ".pdf" `isSuffixOf` name = "application/pdf"
| ".html" `isSuffixOf` name = "text/html"
| ".gif" `isSuffixOf` name = "image/gif"
| ".png" `isSuffixOf` name = "image/png"
| ".jpg" `isSuffixOf` name = "image/jpeg"
| otherwise = "application/octet-stream"