Search in sources :

Example 1 with GzipEncodingProvider

use of io.undertow.server.handlers.encoding.GzipEncodingProvider in project undertow by undertow-io.

the class LoadBalancingProxyTestCase method setup.

@BeforeClass
public static void setup() throws URISyntaxException {
    int port = DefaultServer.getHostPort("default");
    server1 = Undertow.builder().addHttpListener(port + 1, DefaultServer.getHostAddress("default")).setSocketOption(Options.REUSE_ADDRESSES, true).setServerOption(UndertowOptions.NO_REQUEST_TIMEOUT, IDLE_TIMEOUT).setHandler(getRootHandler("s1", "server1")).build();
    server2 = Undertow.builder().addHttpListener(port + 2, DefaultServer.getHostAddress("default")).setSocketOption(Options.REUSE_ADDRESSES, true).setServerOption(UndertowOptions.NO_REQUEST_TIMEOUT, IDLE_TIMEOUT).setHandler(getRootHandler("s2", "server2")).build();
    server1.start();
    server2.start();
    ProxyHandler handler = new ProxyHandler(new LoadBalancingProxyClient().setConnectionsPerThread(4).addHost(new URI("http", null, DefaultServer.getHostAddress("default"), port + 1, null, null, null), "s1").addHost(new URI("http", null, DefaultServer.getHostAddress("default"), port + 2, null, null, null), "s2"), 10000, ResponseCodeHandler.HANDLE_404, false, false, 2);
    DefaultServer.setRootHandler(new EncodingHandler(handler, new ContentEncodingRepository().addEncodingHandler("gzip", new GzipEncodingProvider(), 50, Predicates.truePredicate())));
}
Also used : ContentEncodingRepository(io.undertow.server.handlers.encoding.ContentEncodingRepository) EncodingHandler(io.undertow.server.handlers.encoding.EncodingHandler) URI(java.net.URI) GzipEncodingProvider(io.undertow.server.handlers.encoding.GzipEncodingProvider) BeforeClass(org.junit.BeforeClass)

Example 2 with GzipEncodingProvider

use of io.undertow.server.handlers.encoding.GzipEncodingProvider in project spring-boot by spring-projects.

the class UndertowServletWebServer method configurationCompressionIfNecessary.

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);
}
Also used : ContentEncodingRepository(io.undertow.server.handlers.encoding.ContentEncodingRepository) EncodingHandler(io.undertow.server.handlers.encoding.EncodingHandler) GzipEncodingProvider(io.undertow.server.handlers.encoding.GzipEncodingProvider)

Example 3 with GzipEncodingProvider

use of io.undertow.server.handlers.encoding.GzipEncodingProvider in project wildfly by wildfly.

the class GzipFilter method createHttpHandler.

@Override
public HttpHandler createHttpHandler(final Predicate predicate, ModelNode model, HttpHandler next) {
    EncodingHandler encodingHandler = new EncodingHandler(new ContentEncodingRepository().addEncodingHandler("gzip", new GzipEncodingProvider(), 50, predicate != null ? predicate : Predicates.truePredicate()));
    encodingHandler.setNext(next);
    return encodingHandler;
}
Also used : ContentEncodingRepository(io.undertow.server.handlers.encoding.ContentEncodingRepository) EncodingHandler(io.undertow.server.handlers.encoding.EncodingHandler) GzipEncodingProvider(io.undertow.server.handlers.encoding.GzipEncodingProvider)

Aggregations

ContentEncodingRepository (io.undertow.server.handlers.encoding.ContentEncodingRepository)3 EncodingHandler (io.undertow.server.handlers.encoding.EncodingHandler)3 GzipEncodingProvider (io.undertow.server.handlers.encoding.GzipEncodingProvider)3 URI (java.net.URI)1 BeforeClass (org.junit.BeforeClass)1