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


Java GzipEncodingProvider类代码示例

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


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

示例1: gzip

import io.undertow.server.handlers.encoding.GzipEncodingProvider; //导入依赖的package包/类
public static HttpHandler gzip(HttpHandler next) {
    return new EncodingHandler(new ContentEncodingRepository()
              .addEncodingHandler("gzip",
                  // This 1000 is a priority, not exactly sure what it does.
                  new GzipEncodingProvider(), 1000,
                  // Anything under a content-length of 20 will not be gzipped
                  Predicates.truePredicate()
                  //Predicates.maxContentSize(20) // https://issues.jboss.org/browse/UNDERTOW-1234
                  ))
              .setNext(next);
}
 
开发者ID:StubbornJava,项目名称:StubbornJava,代码行数:12,代码来源:CustomHandlers.java

示例2: configurationCompressionIfNecessary

import io.undertow.server.handlers.encoding.GzipEncodingProvider; //导入依赖的package包/类
private HttpHandler configurationCompressionIfNecessary(HttpHandler httpHandler) {
	if (this.compression == null || !this.compression.getEnabled()) {
		return httpHandler;
	}
	ContentEncodingRepository repository = new ContentEncodingRepository();
	repository.addEncodingHandler("gzip", new GzipEncodingProvider(), 50,
			Predicates.and(getCompressionPredicates(this.compression)));
	return new EncodingHandler(repository).setNext(httpHandler);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:UndertowEmbeddedServletContainer.java

示例3: getHandlers

import io.undertow.server.handlers.encoding.GzipEncodingProvider; //导入依赖的package包/类
private HttpHandler getHandlers(SpurOptions options) {
    // Path handler
    PathTemplateHandler pathTemplateHandler = Handlers.pathTemplate();
    endpointsMap.forEach((path, methodEndpointMap) -> pathTemplateHandler.add(path, new HttpHandler() {
        public void handleRequest(HttpServerExchange exchange) throws Exception {
            // non-blocking
            if (options.blockableHandlersEnabled && exchange.isInIoThread()) {
                // LOGGER.info("Is in IO thread, dispatching for blockableHandlersEnabled...");
                exchange.dispatch(this);
                return;
            }
            // handler code
            // LOGGER.info("STARTING Async");
            invokePathTemplateHandler(options, methodEndpointMap, exchange);
        }
    }));

    // Websocket
    if (!webSocketHandlerMap.isEmpty()) {
        webSocketHandlerMap.forEach((pathPrefix, webSocketHandler) -> {
            LOGGER.info("Adding WS for path: " + webSocketHandler.getPath());
            addWebSocketHandler(pathTemplateHandler, webSocketHandler);
        });
    }

    // SSE
    if (!sseHandlerMap.isEmpty()) {
        sseHandlerMap.forEach(pathTemplateHandler::add);
    }

    // CORS
    HttpHandler httpHandler = Handlers.predicate(exchange -> isValidCorsOrigin(options, getRequestHeader(exchange, Headers.ORIGIN)),
            new CorsHandler(pathTemplateHandler), pathTemplateHandler);

    // Gzip
    if (options.gzipEnabled) {
        httpHandler = new EncodingHandler(new ContentEncodingRepository().addEncodingHandler("gzip", new GzipEncodingProvider(), 50,
                Predicates.maxContentSize(options.gzipMaxSize))).setNext(httpHandler);
    }

    // Custom handlers
    for (RequestFilter requestFilter : requestFilters) {
        httpHandler = Handlers.predicate(requestFilter.getAssertionPredicate(), httpHandler, requestFilter.getFailureHandler());
    }

    // Graceful shutdown
    httpHandler = Handlers.gracefulShutdown(httpHandler);

    // Basic auth
    if (!options.basicAuthUser.isEmpty() && !options.basicAuthPassword.isEmpty()) {
        httpHandler = new BasicAuthHandler(httpHandler, options.basicAuthUser, options.basicAuthPassword);
    }

    // Force HTTPS
    if (options.forceHttps) {
        httpHandler = Handlers.predicate(Predicates.secure(), httpHandler, new RedirectHttpsHandler());
    }

    return httpHandler;
}
 
开发者ID:icha024,项目名称:spur,代码行数:61,代码来源:SpurServer.java

示例4: start

import io.undertow.server.handlers.encoding.GzipEncodingProvider; //导入依赖的package包/类
/**
    * Start the management interface.
    *
    */
public void start() {
	
	Builder builder = Undertow.builder();
	
	// add listener
	builder.addHttpListener(this.managementPort, this.managementInterface);
	
	// set up resource handler
	ClassPathResourceManager classPathManager = new ClassPathResourceManager(Thread.currentThread().getContextClassLoader(), "web");
	ResourceHandler resources = Handlers.resource(classPathManager);
	resources.setWelcomeFiles("index.html");
	resources.setDirectoryListingEnabled(false);
	
	// set up servlet handler
	DeploymentInfo servletBuilder = Servlets.deployment()
			.setClassLoader(Thread.currentThread().getContextClassLoader())
			.setContextPath("/services")
			.setDeploymentName("pincushion-services.war")
			;
	
	// add context parameters
	//servletBuilder.addInitParameter(ResteasyContextParameters.RESTEASY_SERVLET_MAPPING_PREFIX, "/");
	
	// add context listener for bootstrap
	ListenerInfo restBootstrapListener = Servlets.listener(ResteasyBootstrap.class, new ResteasyBootstrapInstanceFactory(this.manager));
	servletBuilder.addListener(restBootstrapListener);
	
	// create and add servlet to servlet handler
	ServletInfo restServletInfo = Servlets.servlet("restEasyHandler", HttpServletDispatcher.class);
	restServletInfo.addInitParam("javax.ws.rs.Application", ManagementApplication.class.getName());
	restServletInfo.addMapping("/*");
	restServletInfo.setLoadOnStartup(1);
	servletBuilder.addServlet(restServletInfo);
	
	// deploy servlets
	DeploymentManager deploymentManager = Servlets.defaultContainer().addDeployment(servletBuilder);
	
	deploymentManager.deploy();
	HttpHandler services = null;
	try {
		services = deploymentManager.start();
	} catch (ServletException e) {
		this.logger.error("Could not start services deployment: {}", e.getLocalizedMessage());
	}

	// create paths
	PathHandler path = Handlers.path(resources);
	if(services != null) {
		path.addPrefixPath("/services", services);
	}
	
	// create encoding repository
	ContentEncodingRepository repo = new ContentEncodingRepository();

       // permit gzip and deflate
	repo.addEncodingHandler("gzip", new GzipEncodingProvider(), 1000);
	repo.addEncodingHandler("deflate", new DeflateEncodingProvider(), 10);
	
	// ensure that everything can be encoded with appropriate compression
	EncodingHandler encoder = new EncodingHandler(path, repo);
	
	// add path handler to server
	builder.setHandler(encoder);
	
	// start undertow server
	this.server = builder.build();
	this.server.start();
	
	this.logger.info("Started undertow management interface at {} on port {}", this.managementInterface, this.managementPort);
}
 
开发者ID:chrisruffalo,项目名称:pincushion,代码行数:75,代码来源:ManagementInterface.java

示例5: GzipEncodingHandler

import io.undertow.server.handlers.encoding.GzipEncodingProvider; //导入依赖的package包/类
/**
 * Creates a new instance of GzipEncodingHandler
 *
 * @param next
 * @param forceCompression if true requests without gzip encoding in
 * Accept-Encoding header will be rejected
 */
public GzipEncodingHandler(HttpHandler next, boolean forceCompression) {
    super(next, new ContentEncodingRepository().addEncodingHandler("gzip", new GzipEncodingProvider(), 50));
    this.forceCompression = forceCompression;
}
 
开发者ID:SoftInstigate,项目名称:restheart,代码行数:12,代码来源:GzipEncodingHandler.java


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