Search in sources :

Example 1 with GZipDecoder

use of io.dropwizard.jersey.gzip.GZipDecoder in project dropwizard by dropwizard.

the class JerseyClientBuilder method build.

private Client build(String name, ExecutorService threadPool, ObjectMapper objectMapper, Validator validator) {
    if (!configuration.isGzipEnabled()) {
        apacheHttpClientBuilder.disableContentCompression(true);
    }
    final Client client = ClientBuilder.newClient(buildConfig(name, threadPool, objectMapper, validator));
    client.register(new JerseyIgnoreRequestUserAgentHeaderFilter());
    // Tie the client to server lifecycle
    if (environment != null) {
        environment.lifecycle().manage(new Managed() {

            @Override
            public void start() throws Exception {
            }

            @Override
            public void stop() throws Exception {
                client.close();
            }
        });
    }
    if (configuration.isGzipEnabled()) {
        client.register(new GZipDecoder());
        client.register(new ConfiguredGZipEncoder(configuration.isGzipEnabledForRequests()));
    }
    return client;
}
Also used : ConfiguredGZipEncoder(io.dropwizard.jersey.gzip.ConfiguredGZipEncoder) GZipDecoder(io.dropwizard.jersey.gzip.GZipDecoder) Client(javax.ws.rs.client.Client) RxClient(org.glassfish.jersey.client.rx.RxClient) Managed(io.dropwizard.lifecycle.Managed)

Aggregations

ConfiguredGZipEncoder (io.dropwizard.jersey.gzip.ConfiguredGZipEncoder)1 GZipDecoder (io.dropwizard.jersey.gzip.GZipDecoder)1 Managed (io.dropwizard.lifecycle.Managed)1 Client (javax.ws.rs.client.Client)1 RxClient (org.glassfish.jersey.client.rx.RxClient)1