当前位置: 首页>>代码示例>>Java>>正文


Java GzipHandler类代码示例

本文整理汇总了Java中org.eclipse.jetty.server.handler.gzip.GzipHandler的典型用法代码示例。如果您正苦于以下问题:Java GzipHandler类的具体用法?Java GzipHandler怎么用?Java GzipHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GzipHandler类属于org.eclipse.jetty.server.handler.gzip包,在下文中一共展示了GzipHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setGzipHandler

import org.eclipse.jetty.server.handler.gzip.GzipHandler; //导入依赖的package包/类
/**
 * @param gzipHandler The {@link GzipHandler} to set on this context.
 */
public void setGzipHandler(GzipHandler gzipHandler)
{
    if (isStarted())
        throw new IllegalStateException("STARTED");

    Handler next=null;
    if (_gzipHandler!=null)
    {
        next=_gzipHandler.getHandler();
        _gzipHandler.setHandler(null);
        replaceHandler(_gzipHandler,gzipHandler);
    }
    
    _gzipHandler = gzipHandler;
    if (next!=null && _gzipHandler.getHandler()==null)
        _gzipHandler.setHandler(next);
    relinkHandlers();
}
 
开发者ID:xiaomin0322,项目名称:marathon-auth-plugin,代码行数:22,代码来源:ServletContextHandler.java

示例2: addStaticResourceConfig

import org.eclipse.jetty.server.handler.gzip.GzipHandler; //导入依赖的package包/类
private void addStaticResourceConfig(ServletContextHandler context) {
    URL webappLocation = getClass().getResource("/webapp/index.html");
    if (webappLocation == null) {
        System.err.println("Couldn't get webapp location.");
    } else {
        try {
            URI webRootUri = URI.create(webappLocation.toURI().toASCIIString().replaceFirst("/index.html$", "/"));
            context.setBaseResource(Resource.newResource(webRootUri));
            context.setWelcomeFiles(new String[]{"index.html"});

            GzipHandler gzipHandler = new GzipHandler();
            gzipHandler.setIncludedMethods(HttpMethod.GET.name(), HttpMethod.POST.name(), HttpMethod.PUT.name());
            context.setGzipHandler(gzipHandler);
            context.addFilter(TryFilesFilter.class, "*", EnumSet.of(DispatcherType.REQUEST));
        } catch (URISyntaxException | MalformedURLException e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:sparkled,项目名称:sparkled,代码行数:20,代码来源:RestApiServerImpl.java

示例3: createRestService

import org.eclipse.jetty.server.handler.gzip.GzipHandler; //导入依赖的package包/类
private Handler createRestService() {
    ResourceConfig rc = new ResourceConfig();
    rc.register(systemResource);
    rc.register(appResource);
    rc.register(JacksonFeature.class);
    rc.register(CORSFilter.class);
    SwaggerDocs.registerSwaggerJsonResource(rc);
    rc.addProperties(new HashMap<String,Object>() {{
        // Turn off buffering so results can be streamed
        put(ServerProperties.OUTBOUND_CONTENT_LENGTH_BUFFER, 0);
    }});

    ServletHolder holder = new ServletHolder(new ServletContainer(rc));

    ServletContextHandler sch = new ServletContextHandler();
    sch.setContextPath("/api/v1");
    sch.addServlet(holder, "/*");

    GzipHandler gzipHandler = new GzipHandler();
    gzipHandler.setHandler(sch);
    return gzipHandler;
}
 
开发者ID:danielflower,项目名称:app-runner,代码行数:23,代码来源:WebServer.java

示例4: jettyEmbeddedServletContainerFactory

import org.eclipse.jetty.server.handler.gzip.GzipHandler; //导入依赖的package包/类
@Bean
public JettyEmbeddedServletContainerFactory jettyEmbeddedServletContainerFactory(
        @Value("${server.port:8080}") final String port,
        @Value("${jetty.threadPool.maxThreads:200}") final String maxThreads,
        @Value("${jetty.threadPool.minThreads:8}") final String minThreads,
        @Value("${jetty.threadPool.idleTimeout:60000}") final String idleTimeout) {
    final JettyEmbeddedServletContainerFactory factory =
            new JettyEmbeddedServletContainerFactory(Integer.valueOf(port));
    factory.addServerCustomizers((JettyServerCustomizer) server -> {
        final QueuedThreadPool threadPool = server.getBean(QueuedThreadPool.class);
        threadPool.setMaxThreads(Integer.valueOf(maxThreads));
        threadPool.setMinThreads(Integer.valueOf(minThreads));
        threadPool.setIdleTimeout(Integer.valueOf(idleTimeout));

        final GzipHandler gzipHandler = new GzipHandler();
        gzipHandler.setHandler(server.getHandler());
        gzipHandler.setSyncFlush(true);
        server.setHandler(gzipHandler);
    });
    return factory;
}
 
开发者ID:zalando,项目名称:nakadi,代码行数:22,代码来源:JettyConfig.java

示例5: doPut

import org.eclipse.jetty.server.handler.gzip.GzipHandler; //导入依赖的package包/类
@Override
protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    final String path = req.getPathInfo();
    if (path != null && byName.matcher(path).matches()) {
        final String key = path.trim().substring(1);
        InputStream inputStream = req.getInputStream();
        if (GzipHandler.GZIP.equalsIgnoreCase(req.getHeader(HttpHeaders.CONTENT_ENCODING))) {
            inputStream = new GZIPInputStream(inputStream);
        }
        try (InputStreamReader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8)) {
            final String body = CharStreams.toString(reader);
            writeResponse(resp, circuitBreakersResource.modifyCircuitBreaker(key, body));
        }
    } else {
        resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
    }
}
 
开发者ID:yammer,项目名称:tenacity,代码行数:18,代码来源:TenacityCircuitBreakersServlet.java

示例6: setGzipEnabled

import org.eclipse.jetty.server.handler.gzip.GzipHandler; //导入依赖的package包/类
/**
 * Calling this method will cause the server to compress the responses if the client supports GZIP responses and the resource mime type is not of a known compressed type.
 *In most cases it should be enabled.
 */
public void setGzipEnabled(boolean b) {
	if (b) {
		gzipHandler = new GzipHandler();
		gzipHandler.setIncludedMethods(HttpMethod.POST.toString(), HttpMethod.GET.toString());
	} else {
		gzipHandler = null;
	}
}
 
开发者ID:AnywhereSoftware,项目名称:B4J_Server,代码行数:13,代码来源:ServerWrapper.java

示例7: 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

示例8: 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);
    }
 
开发者ID:factoryfx,项目名称:factoryfx,代码行数:32,代码来源:JettyServer.java

示例9: getHandlerCollection

import org.eclipse.jetty.server.handler.gzip.GzipHandler; //导入依赖的package包/类
private HandlerCollection getHandlerCollection(
        ServerConfig serverConfig,
        ServletPathsConfig servletPathsConfig,
        ServletHolder jdiscServlet,
        ComponentRegistry<ServletHolder> servletHolders,
        FilterHolder jDiscFilterInvokerFilter,
        RequestLog requestLog) {

    ServletContextHandler servletContextHandler = createServletContextHandler();

    servletHolders.allComponentsById().forEach((id, servlet) -> {
        String path = getServletPath(servletPathsConfig, id);
        servletContextHandler.addServlet(servlet, path);
        servletContextHandler.addFilter(jDiscFilterInvokerFilter, path, EnumSet.allOf(DispatcherType.class));
    });

    servletContextHandler.addServlet(jdiscServlet, "/*");

    GzipHandler gzipHandler = newGzipHandler(serverConfig);
    gzipHandler.setHandler(servletContextHandler);

    StatisticsHandler statisticsHandler = newStatisticsHandler();
    statisticsHandler.setHandler(gzipHandler);

    RequestLogHandler requestLogHandler = new RequestLogHandler();
    requestLogHandler.setRequestLog(requestLog);

    HandlerCollection handlerCollection = new HandlerCollection();
    handlerCollection.setHandlers(new Handler[]{statisticsHandler, requestLogHandler});
    return handlerCollection;
}
 
开发者ID:vespa-engine,项目名称:vespa,代码行数:32,代码来源:JettyHttpServer.java

示例10: 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;
}
 
开发者ID:vespa-engine,项目名称:vespa,代码行数:8,代码来源:JettyHttpServer.java

示例11: 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;
}
 
开发者ID:AndreasKl,项目名称:embedded-jetty-http2,代码行数:8,代码来源:Application.java

示例12: startImpl

import org.eclipse.jetty.server.handler.gzip.GzipHandler; //导入依赖的package包/类
protected String startImpl(ServletHolder holder, int port) throws Exception {
    holder.setInitOrder(0);

    {
        MultipartConfig multipartConfig = frontServletClass.getAnnotation(MultipartConfig.class);
        if (multipartConfig != null)

            holder.getRegistration().setMultipartConfig(new MultipartConfigElement(multipartConfig));
        else
            holder.getRegistration().setMultipartConfig(new MultipartConfigElement(""));
    }

    ServletContextHandler ctx = new ServletContextHandler(ServletContextHandler.SESSIONS);
    ctx.setContextPath("");
    ctx.addServlet(holder, "/*");

    ctx.setResourceBase(Paths.get("").toString());

    server = new Server();
    ServerConnector connector = new ServerConnector(server);
    connector.setPort(port);
    server.setConnectors(new Connector[] { connector });

    GzipHandler gzip = new GzipHandler();
    gzip.setHandler(ctx);
    server.setHandler(gzip);
    server.start();

    this.servlet = (FrontServletBase) holder.getServlet();

    String host = connector.getHost();
    if (host == null) {
        host = "localhost";
    }
    return String.format("http://%s:%d", host, connector.getLocalPort());
}
 
开发者ID:ruediste,项目名称:rise,代码行数:37,代码来源:RiseServer.java

示例13: 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;
}
 
开发者ID:spotify,项目名称:heroic,代码行数:37,代码来源:HttpServer.java

示例14: getGzipHandler

import org.eclipse.jetty.server.handler.gzip.GzipHandler; //导入依赖的package包/类
private Handler getGzipHandler(Handler handler) {
    GzipHandler gzipHandler = new GzipHandler();
    gzipHandler.addIncludedMethods("GET", "POST", "PUT", "DELETE", "PATCH");
    gzipHandler.addIncludedPaths("/*");
    gzipHandler.setHandler(handler);
    return gzipHandler;
}
 
开发者ID:flipkart-incubator,项目名称:Poseidon,代码行数:8,代码来源:Poseidon.java

示例15: provideGzipHandler

import org.eclipse.jetty.server.handler.gzip.GzipHandler; //导入依赖的package包/类
@Provides(type = Type.SET)
ContextConfigurator provideGzipHandler() {
  return new ContextConfigurator() {
    @Override
    public void init(ServletContextHandler context) {
      context.setGzipHandler(new GzipHandler());
    }
  };
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:10,代码来源:WebServerModule.java


注:本文中的org.eclipse.jetty.server.handler.gzip.GzipHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。