本文整理汇总了Java中org.eclipse.jetty.server.handler.gzip.GzipHandler.setCompressionLevel方法的典型用法代码示例。如果您正苦于以下问题:Java GzipHandler.setCompressionLevel方法的具体用法?Java GzipHandler.setCompressionLevel怎么用?Java GzipHandler.setCompressionLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jetty.server.handler.gzip.GzipHandler
的用法示例。
在下文中一共展示了GzipHandler.setCompressionLevel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newGzipHandler
import org.eclipse.jetty.server.handler.gzip.GzipHandler; //导入方法依赖的package包/类
private GzipHandler newGzipHandler(ServerConfig serverConfig) {
GzipHandler gzipHandler = new GzipHandlerWithVaryHeaderFixed();
gzipHandler.setCompressionLevel(serverConfig.responseCompressionLevel());
gzipHandler.setCheckGzExists(false);
gzipHandler.setIncludedMethods("GET", "POST");
return gzipHandler;
}
示例2: createHandlers
import org.eclipse.jetty.server.handler.gzip.GzipHandler; //导入方法依赖的package包/类
private HandlerCollection createHandlers() {
final WebAppContext webApp = new WebAppContext();
webApp.setContextPath(contextPath);
webApp.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
webApp.getSessionHandler().setMaxInactiveInterval(sessionTimeout * 60);
// GZIP handler
final GzipHandler gzipHandler = new GzipHandler();
gzipHandler.addIncludedMimeTypes("text/html", "text/xml", "text/css", "text/plain", "text/javascript", "application/javascript", "application/json", "application/xml");
gzipHandler.setIncludedMethods("GET", "POST");
gzipHandler.setCompressionLevel(9);
gzipHandler.setHandler(webApp);
if (Strings.isNullOrEmpty(webAppLocation)) {
webApp.setWar(getShadedWarUrl());
} else {
webApp.setWar(webAppLocation);
}
// Request log handler
final RequestLogHandler log = new RequestLogHandler();
log.setRequestLog(createRequestLog());
// Redirect root context handler
MovedContextHandler rootRedirect = new MovedContextHandler();
rootRedirect.setContextPath("/");
rootRedirect.setNewContextURL(contextPath);
rootRedirect.setPermanent(true);
// Put rootRedirect at the end!
return new HandlerCollection(log, gzipHandler, rootRedirect);
}