Changeset 2837 for trunk/server/common/oursrc/scripts-static-cat
- Timestamp:
- Apr 10, 2017, 4:56:03 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server/common/oursrc/scripts-static-cat/StaticCat.hs
r2796 r2837 23 23 import System.Posix.Handle 24 24 25 encodings :: M.Map String String26 encodings = M.fromList [27 (".bz2", "bzip2"),28 (".gz", "gzip"),29 (".z", "compress")30 ]31 32 25 types :: M.Map String String 33 26 types = M.fromList [ … … 49 42 (".jpeg", "image/jpeg"), 50 43 (".jpg", "image/jpeg"), 51 (".js", "application/ x-javascript"),44 (".js", "application/javascript"), 52 45 (".mid", "audio/midi"), 53 46 (".midi", "audio/midi"), … … 88 81 (".swf", "application/x-shockwave-flash"), 89 82 (".tar", "application/x-tar"), 90 (".tgz", "application/ x-gzip"),83 (".tgz", "application/gzip"), 91 84 (".tif", "image/tiff"), 92 85 (".tiff", "image/tiff"), … … 109 102 (".xltx", "application/vnd.openxmlformats-officedocument.spreadsheetml.template"), 110 103 (".xml", "text/xml"), 111 (".xsl", " text/xml"),104 (".xsl", "application/xslt+xml"), 112 105 (".zip", "application/zip") 113 106 ] … … 126 119 127 120 checkExtension :: FilePath -> CGI () 128 checkExtension file = do 129 let (base, ext) = splitExtension file 130 ext' <- case M.lookup (map toLower ext) encodings of 131 Nothing -> return ext 132 Just e -> do 133 setHeader "Content-Encoding" e 134 return $ takeExtension base 135 136 case M.lookup (map toLower ext') types of 121 checkExtension file = 122 case M.lookup (map toLower (takeExtension file)) types of 137 123 Nothing -> throw Forbidden 138 124 Just t -> setHeader "Content-Type" t
Note: See TracChangeset
for help on using the changeset viewer.