Changeset 2837


Ignore:
Timestamp:
Apr 10, 2017, 4:56:03 AM (5 years ago)
Author:
andersk
Message:
Improve Content-Type and Content-Encoding headers

Since Chrome has started decompressing tarballs served with
Content-Encoding: x-gzip on download, we don’t want to be sending that
by default.

Remove all the custom AddType and AddEncoding directives from
httpd.conf (let it pick up MIME types from /etc/mime.types).  Do not
set Content-Encoding in static-cat, and fix some of the hard-coded
MIME types there.

Location:
trunk/server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server/common/oursrc/scripts-static-cat/StaticCat.hs

    r2796 r2837  
    2323import System.Posix.Handle
    2424
    25 encodings :: M.Map String String
    26 encodings = M.fromList [
    27              (".bz2", "bzip2"),
    28              (".gz", "gzip"),
    29              (".z", "compress")
    30             ]
    31 
    3225types :: M.Map String String
    3326types = M.fromList [
     
    4942         (".jpeg", "image/jpeg"),
    5043         (".jpg", "image/jpeg"),
    51          (".js", "application/x-javascript"),
     44         (".js", "application/javascript"),
    5245         (".mid", "audio/midi"),
    5346         (".midi", "audio/midi"),
     
    8881         (".swf", "application/x-shockwave-flash"),
    8982         (".tar", "application/x-tar"),
    90          (".tgz", "application/x-gzip"),
     83         (".tgz", "application/gzip"),
    9184         (".tif", "image/tiff"),
    9285         (".tiff", "image/tiff"),
     
    109102         (".xltx", "application/vnd.openxmlformats-officedocument.spreadsheetml.template"),
    110103         (".xml", "text/xml"),
    111          (".xsl", "text/xml"),
     104         (".xsl", "application/xslt+xml"),
    112105         (".zip", "application/zip")
    113106        ]
     
    126119
    127120checkExtension :: 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
     121checkExtension file =
     122  case M.lookup (map toLower (takeExtension file)) types of
    137123    Nothing -> throw Forbidden
    138124    Just t -> setHeader "Content-Type" t
  • trunk/server/fedora/config/etc/httpd/conf/httpd.conf

    r2822 r2837  
    218218
    219219<IfModule mod_mime.c>
    220     AddType application/xhtml+xml         .xhtml
    221     AddType application/http-index-format .hti
    222     AddType text/html                     .html
    223     AddType text/css                      .css
    224     AddType text/xsl                      .xslt
    225     AddType application/x-javascript      .js
    226     AddType application/xml               .xml
    227     AddType image/svg+xml                 .svg
    228     AddType application/vnd.mozilla.xul+xml .xul
    229     AddType application/rdf+xml             .rdf
    230     AddType application/x-xpinstall         .xpi
    231     AddType text/xml .xsl
    232     AddType text/html .shtml
    233220    AddHandler server-parsed .shtml
    234 
    235     AddEncoding x-compress Z
    236     AddEncoding x-gzip gz tgz
    237221
    238222    AddLanguage da .dk
     
    259243        LanguagePriority en da nl et fr de el it ja pl pt pt-br ltz ca es sv
    260244    </IfModule>
    261 
    262     AddType application/x-tar .tgz
    263     AddType image/bmp .bmp
    264 
    265     AddType text/x-hdml .hdml
    266245</IfModule>
    267246
     
    318297    Listen 443
    319298    Listen 444
    320 
    321     AddType application/x-x509-ca-cert .crt
    322     AddType application/x-pkcs7-crl    .crl
    323299
    324300    # This directive allows insecure renegotiations to succeed for browsers
Note: See TracChangeset for help on using the changeset viewer.