本文整理汇总了Java中org.eclipse.jetty.server.handler.gzip.GzipHandler.setMinGzipSize方法的典型用法代码示例。如果您正苦于以下问题:Java GzipHandler.setMinGzipSize方法的具体用法?Java GzipHandler.setMinGzipSize怎么用?Java GzipHandler.setMinGzipSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jetty.server.handler.gzip.GzipHandler
的用法示例。
在下文中一共展示了GzipHandler.setMinGzipSize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createGzipHandler
import org.eclipse.jetty.server.handler.gzip.GzipHandler; //导入方法依赖的package包/类
@Override
public HandlerWrapper createGzipHandler(Compression compression) {
GzipHandler handler = new GzipHandler();
handler.setMinGzipSize(compression.getMinResponseSize());
handler.setIncludedMimeTypes(compression.getMimeTypes());
if (compression.getExcludedUserAgents() != null) {
handler.setExcludedAgentPatterns(compression.getExcludedUserAgents());
}
return handler;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:JettyEmbeddedServletContainerFactory.java
示例2: JettyServer
import org.eclipse.jetty.server.handler.gzip.GzipHandler; //导入方法依赖的package包/类
public JettyServer(List<HttpServerConnectorCreator> connectors, List<Object> resources) {
server=new org.eclipse.jetty.server.Server();
currentConnectors.addAll(connectors);
for (HttpServerConnectorCreator creator : currentConnectors) {
creator.addToServer(server);
}
rootServlet = new UpdateableServlet(new ServletContainer(jerseySetup(resources)));
ServletHolder holder = new ServletHolder(rootServlet);
ServletContextHandler contextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
contextHandler.addServlet( holder, "/*");
ErrorHandler errorHandler = new ErrorHandler();
errorHandler.setShowStacks(true);
contextHandler.setErrorHandler(errorHandler);
GzipHandler gzipHandler = new GzipHandler();
// HashSet<String> mimeTypes = new HashSet<>();
// mimeTypes.add("text/html");
// mimeTypes.add("text/plain");
// mimeTypes.add("text/css");
// mimeTypes.add("application/x-javascript");
// mimeTypes.add("application/json");
gzipHandler.setMinGzipSize(0);
gzipHandler.setHandler(contextHandler);
HandlerCollection handlers = new HandlerList();
additionalHandlers().forEach(handler -> handlers.addHandler(handler));
handlers.addHandler(gzipHandler);
server.setHandler(handlers);
}
示例3: createGzipHandler
import org.eclipse.jetty.server.handler.gzip.GzipHandler; //导入方法依赖的package包/类
private GzipHandler createGzipHandler() {
GzipHandler gzipHandler = new GzipHandler();
gzipHandler.setIncludedPaths("/*");
gzipHandler.setMinGzipSize(0);
gzipHandler.setIncludedMimeTypes("text/plain", "text/html");
return gzipHandler;
}
示例4: setupHandler
import org.eclipse.jetty.server.handler.gzip.GzipHandler; //导入方法依赖的package包/类
private HandlerCollection setupHandler() throws Exception {
final ResourceConfig resourceConfig = setupResourceConfig();
final ServletContainer servlet = new ServletContainer(resourceConfig);
final ServletHolder jerseyServlet = new ServletHolder(servlet);
// Initialize and register Jersey ServletContainer
jerseyServlet.setInitOrder(1);
// statically provide injector to jersey application.
final ServletContextHandler context =
new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
context.setContextPath("/");
GzipHandler gzip = new GzipHandler();
gzip.setIncludedMethods("POST");
gzip.setMinGzipSize(860);
gzip.setIncludedMimeTypes("application/json");
context.setGzipHandler(gzip);
context.addServlet(jerseyServlet, "/*");
context.addFilter(new FilterHolder(new ShutdownFilter(stopping, mapper)), "/*", null);
context.setErrorHandler(new JettyJSONErrorHandler(mapper));
final RequestLogHandler requestLogHandler = new RequestLogHandler();
requestLogHandler.setRequestLog(new Slf4jRequestLog());
final RewriteHandler rewrite = new RewriteHandler();
makeRewriteRules(rewrite);
final HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[]{rewrite, context, requestLogHandler});
return handlers;
}
示例5: start
import org.eclipse.jetty.server.handler.gzip.GzipHandler; //导入方法依赖的package包/类
public void start() {
System.setProperty("java.net.preferIPv4Stack", "true");//TODO optional?
server = new org.eclipse.jetty.server.Server();
// HashSessionIdManager sessionIdManager = new HashSessionIdManager();
// server.setSessionIdManager(sessionIdManager);
connector = new NetworkTrafficServerConnector(server);
connector.setPort(httpPort);
connector.setHost(host);
server.addConnector(connector);
ServletContextHandler contextHandler = new ServletContextHandler();
SessionHandler sessionHandler = new SessionHandler();
// HashSessionManager sessionManager = new HashSessionManager();
// sessionManager.setMaxInactiveInterval(sessionTimeoutS);
// sessionManager.setSessionCookie(sessionManager.getSessionCookie()+httpPort); //avoid session mix up for 2 server running as localhost
// sessionHandler.setSessionManager(sessionManager);
contextHandler.setSessionHandler(sessionHandler);
contextHandler.addServlet(new ServletHolder(new ServletContainer(jerseySetup(restResource))), "/applicationServer/*");
ErrorHandler errorHandler = new ErrorHandler();
errorHandler.setShowStacks(true);
contextHandler.setErrorHandler(errorHandler);
GzipHandler gzipHandler = new GzipHandler();
// HashSet<String> mimeTypes = new HashSet<>();
// mimeTypes.add("text/html");
// mimeTypes.add("text/plain");
// mimeTypes.add("text/css");
// mimeTypes.add("application/x-javascript");
// mimeTypes.add("application/json");
gzipHandler.setMinGzipSize(0);
// gzipHandler.setMimeTypes(mimeTypes);
HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[]{resourceHandler, contextHandler});
gzipHandler.setHandler(handlers);
server.setHandler(gzipHandler);
try {
server.start();
} catch (Exception e) {
throw new RuntimeException(e);
}
}