@Signature public void __construct() { gzipHandler = new GzipHandler(); }
/** * Enables compression for the specified handler. * * @param handler handler to enable compression for * @return compression enabled handler */ private Handler gzip(final Handler handler) { final GzipHandler gzip = new GzipHandler(); gzip.setIncludedMethods("GET", "POST", "PUT", "DELETE"); gzip.setHandler(handler); return gzip; }
static GzipHandler gzipHandler() { GzipHandler gzipHandler = new GzipHandler(); gzipHandler.addIncludedMimeTypes( "application/javascript", "application/json", "application/vnd.go.cd.v1+json", "application/vnd.go.cd.v2+json", "application/vnd.go.cd.v3+json", "application/vnd.go.cd.v4+json", "application/vnd.go.cd.v5+json", "application/vnd.go.cd.v6+json", "application/vnd.go.cd.v7+json", "application/vnd.go.cd.v8+json", "application/vnd.go.cd.v9+json", "application/xhtml+xml", "image/svg+xml", "text/css", "text/html", "text/plain", "text/xml" ); gzipHandler.addIncludedMethods("HEAD", "GET", "POST", "PUT", "PATCH", "DELETE"); return gzipHandler; }
@Override public AbstractHandler configureHandler() throws Exception { GzipHandler gzipHandler = new GzipHandler(); gzipHandler.setHandler(new StreamHandler()); return gzipHandler; }
public GzipHandler build(@Nullable Handler handler) { final GzipHandler gzipHandler = new GzipHandler(); gzipHandler.setHandler(handler); gzipHandler.setMinGzipSize((int) minimumEntitySize.toBytes());
public static GzipHandler wrapWithDefaultGzipHandler(final Handler handler, int inflateBufferSize, int compressionLevel) { GzipHandler gzipHandler = new GzipHandler(); gzipHandler.setMinGzipSize(0); gzipHandler.setIncludedMethods(GZIP_METHODS); gzipHandler.setInflateBufferSize(inflateBufferSize); gzipHandler.setCompressionLevel(compressionLevel); // We don't actually have any precomputed .gz resources, and checking for them inside jars is expensive. gzipHandler.setCheckGzExists(false); gzipHandler.setHandler(handler); return gzipHandler; }
GzipHandler gzipHandler = new GzipHandler(); gzipHandler.setIncludedMethods("GET", "POST", "PUT", "DELETE"); gzipHandler.setMinGzipSize(1024);
GzipHandler gzipHandler = new GzipHandler(); gzipHandler.setIncludedMimeTypes("application/json"); gzipHandler.addIncludedMethods("GET","POST");
final GzipHandler gzipHandler = new GzipHandler(); gzipHandler.setHandler(context); gzipHandler.addIncludedMethods(HttpMethod.POST);
GzipHandler gzipHandler = new GzipHandler(); gzipHandler.setIncludedMimeTypes("text/html,text/plain,text/xml,text/css,application/javascript,text/javascript,application/json"); gzipHandler.setHandler(handlerlist2);
public static void main(String[] args) throws Exception { WebAppMain.standAloneMode = true; Logo.print(true); initializeLogDir(); final ConfigureAdaptor conf = ConfigureManager.getConfigure(); connectScouterCollector(); final Server server = new Server(conf.getNetHttpPort()); HandlerCollection handlers = new HandlerCollection(); RequestLogHandler requestLogHandler = setRequestLogHandler(); handlers.addHandler(requestLogHandler); ServletContextHandler servletContextHandler = setWebAppContext(); if (conf.isNetHttpApiGzipEnabled()) { GzipHandler gzipHandler = new GzipHandler(); gzipHandler.setIncludedMethods("GET", "POST", "PUT", "DELETE"); gzipHandler.setMinGzipSize(1024); gzipHandler.setHandler(servletContextHandler); handlers.addHandler(gzipHandler); } else { handlers.addHandler(servletContextHandler); } server.setHandler(handlers); setWebSocketServer(servletContextHandler); try { server.start(); waitOnExit(server); } catch (Exception e) { e.printStackTrace(); } }
static HandlerWrapper createGzipHandlerWrapper(Compression compression) { GzipHandler handler = new GzipHandler(); handler.setMinGzipSize((int) compression.getMinResponseSize().toBytes()); handler.setIncludedMimeTypes(compression.getMimeTypes()); for (HttpMethod httpMethod : HttpMethod.values()) { handler.addIncludedMethods(httpMethod.name()); } if (compression.getExcludedUserAgents() != null) { handler.setExcludedAgentPatterns(compression.getExcludedUserAgents()); } return handler; }
GzipHandler gzipHandler = new GzipHandler(); gzipHandler.setIncludedMimeTypes("text/html,text/plain,text/xml,text/css,application/javascript,text/javascript,application/json"); gzipHandler.setHandler(handlerlist2);
/** * Run couchdb-lucene. */ public static void main(String[] args) throws Exception { final Config config = new Config(); final File dir = config.getDir(); final Server server = new Server(); final ServerConnector connector = new ServerConnector(server); connector.setHost(config.getConfiguration().getString("lucene.host", "localhost")); connector.setPort(config.getConfiguration().getInt("lucene.port", 5985)); LOG.info("Accepting connections with " + connector); server.addConnector(connector); server.setStopAtShutdown(true); final LuceneServlet servlet = new LuceneServlet(config.getClient(), dir, config.getConfiguration()); final ServletContextHandler context = new ServletContextHandler(server, "/", ServletContextHandler.NO_SESSIONS | ServletContextHandler.NO_SECURITY); context.addServlet(new ServletHolder(servlet), "/*"); context.setErrorHandler(new JSONErrorHandler()); context.setGzipHandler(new GzipHandler()); server.setHandler(context); server.start(); server.join(); }
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); }
private JettyFusekiWebapp(JettyServerConfig config) { this.serverConfig = config ; buildServerWebapp(serverConfig.contextPath, serverConfig.jettyConfigFile) ; if ( mgtConnector == null ) mgtConnector = serverConnector ; if ( config.enableCompression ) { GzipHandler gzipHandler = new GzipHandler(); gzipHandler.setHandler(server.getHandler()); server.setHandler(gzipHandler); } }
private JettyFusekiWebapp(JettyServerConfig config) { this.serverConfig = config ; buildServerWebapp(serverConfig.contextPath, serverConfig.jettyConfigFile) ; if ( mgtConnector == null ) mgtConnector = serverConnector ; if ( config.enableCompression ) { GzipHandler gzipHandler = new GzipHandler(); gzipHandler.setHandler(server.getHandler()); server.setHandler(gzipHandler); } }
public Handler wrapWithGzipHandler(Handler handler) { if (config.getBoolean(RestConfig.ENABLE_GZIP_COMPRESSION_CONFIG)) { GzipHandler gzip = new GzipHandler(); gzip.setIncludedMethods("GET", "POST"); gzip.setHandler(handler); return gzip; } return handler; }
private Handler createRootHandler(ServletContextHandler servletContextHandler) { ResourceHandler resourceHandler = createResourceHandler(); HandlerList handlers = new HandlerList(); handlers.setHandlers(new Handler[]{resourceHandler, servletContextHandler}); GzipHandler gzipHandler = new GzipHandler(); gzipHandler.setHandler(handlers); return gzipHandler; }
public static GzipHandler wrapWithDefaultGzipHandler(final Handler handler, int inflateBufferSize, int compressionLevel) { GzipHandler gzipHandler = new GzipHandler(); gzipHandler.setMinGzipSize(0); gzipHandler.setIncludedMethods(GZIP_METHODS); gzipHandler.setInflateBufferSize(inflateBufferSize); gzipHandler.setCompressionLevel(compressionLevel); // We don't actually have any precomputed .gz resources, and checking for them inside jars is expensive. gzipHandler.setCheckGzExists(false); gzipHandler.setHandler(handler); return gzipHandler; }