Console: Fix gzip enable logic

Don't compress js
Set charset for war resources
This commit is contained in:
zzz
2018-03-10 14:53:57 +00:00
parent fa85c0c50b
commit fe808a8800
3 changed files with 25 additions and 5 deletions

View File

@ -377,8 +377,16 @@ class BasicServlet extends HttpServlet
protected void writeHeaders(HttpServletResponse response,HttpContent content,long count)
throws IOException
{
if (content.getContentType()!=null && response.getContentType()==null)
response.setContentType(content.getContentType());
String rtype = response.getContentType();
String ctype = content.getContentType();
if (rtype != null) {
if (rtype.equals("application/javascript"))
response.setCharacterEncoding("ISO-8859-1");
} else if (ctype != null) {
response.setContentType(ctype);
if (ctype.equals("application/javascript"))
response.setCharacterEncoding("ISO-8859-1");
}
response.setHeader("X-Content-Type-Options", "nosniff");
long lml = content.getLastModified();
if (lml > 0)

View File

@ -43,9 +43,18 @@ public class HostCheckHandler extends GzipHandler
_portMapper = ctx.portMapper();
_listenHosts = new HashSet<String>(8);
setMinGzipSize(64*1024);
if (!_context.getBooleanPropertyDefaultTrue(PROP_GZIP)) {
addIncludedMimeTypes("application/x-javascript", "application/xhtml+xml", "application/xml",
"image/svg+xml", "text/css", "text/html", "text/plain");
if (_context.getBooleanPropertyDefaultTrue(PROP_GZIP)) {
addIncludedMimeTypes(
// our js is very small
//"application/javascript", "application/x-javascript",
"application/xhtml+xml", "application/xml",
"image/svg+xml", "text/css", "text/html", "text/plain"
);
} else {
// poorly documented, but we must put something in,
// if empty all are matched,
// see IncludeExcludeSet
addIncludedMimeTypes("xyzzy");
}
}

View File

@ -96,6 +96,9 @@ public class LocaleWebAppHandler extends HandlerWrapper
}
}
}
} else if (pathInContext.startsWith("/js/")) {
// war internal
httpResponse.setCharacterEncoding("ISO-8859-1");
}
//System.err.println("New path: " + newPath);
super.handle(newPath, baseRequest, httpRequest, httpResponse);