org.glassfish.jersey.client.filter.EncodingFilter Java Examples
The following examples show how to use
org.glassfish.jersey.client.filter.EncodingFilter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HttpClientCommon.java From datacollector with Apache License 2.0 | 6 votes |
private void configureCompression(ClientBuilder clientBuilder) { if (jerseyClientConfig.httpCompression != null) { switch (jerseyClientConfig.httpCompression) { case SNAPPY: clientBuilder.register(SnappyEncoder.class); break; case GZIP: clientBuilder.register(GZipEncoder.class); break; case NONE: default: break; } clientBuilder.register(EncodingFilter.class); } }
Example #2
Source File: OpenTsdb.java From metrics-opentsdb with Apache License 2.0 | 5 votes |
private OpenTsdb(String baseURL, Integer connectionTimeout, Integer readTimeout, boolean gzipEnabled) { ClientBuilder builder = ClientBuilder.newBuilder() .register(JacksonFeature.class); if (gzipEnabled) { builder = builder.register(GZipEncoder.class) .register(EncodingFilter.class) .property(ClientProperties.USE_ENCODING, "gzip"); } final Client client = builder.build(); client.property(ClientProperties.CONNECT_TIMEOUT, connectionTimeout); client.property(ClientProperties.READ_TIMEOUT, readTimeout); this.apiResource = client.target(baseURL); }
Example #3
Source File: BaseApiTest.java From hugegraph with Apache License 2.0 | 4 votes |
public RestClient(String url) { this.client = ClientBuilder.newClient(); this.client.register(EncodingFilter.class); this.client.register(GZipEncoder.class); this.target = this.client.target(url); }
Example #4
Source File: ElasticConnectionPool.java From dremio-oss with Apache License 2.0 | 4 votes |
public void connect() throws IOException { final ClientConfig configuration = new ClientConfig(); configuration.property(ClientProperties.READ_TIMEOUT, readTimeoutMillis); final AWSCredentialsProvider awsCredentialsProvider = elasticsearchAuthentication.getAwsCredentialsProvider(); if (awsCredentialsProvider != null) { configuration.property(REGION_NAME, elasticsearchAuthentication.getRegionName()); configuration.register(ElasticsearchRequestClientFilter.class); configuration.register(new InjectableAWSCredentialsProvider(awsCredentialsProvider), InjectableAWSCredentialsProvider.class); } final ClientBuilder builder = ClientBuilder.newBuilder() .withConfig(configuration); switch(sslMode) { case UNSECURE: builder.sslContext(SSLHelper.newAllTrustingSSLContext("SSL")); // fall-through case VERIFY_CA: builder.hostnameVerifier(SSLHelper.newAllValidHostnameVerifier()); // fall-through case STRICT: break; case OFF: // no TLS/SSL configuration } client = builder.build(); client.register(GZipEncoder.class); client.register(DeflateEncoder.class); client.register(EncodingFilter.class); if (REQUEST_LOGGER.isDebugEnabled()) { java.util.logging.Logger julLogger = java.util.logging.Logger.getLogger(REQUEST_LOGGER_NAME); client.register(new LoggingFeature( julLogger, Level.FINE, REQUEST_LOGGER.isTraceEnabled() ? LoggingFeature.Verbosity.PAYLOAD_TEXT : LoggingFeature.Verbosity.HEADERS_ONLY, 65536)); } final JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider(); provider.setMapper(ElasticMappingSet.MAPPER); // Disable other JSON providers. client.property( PropertiesHelper.getPropertyNameForRuntime(InternalProperties.JSON_FEATURE, client.getConfiguration().getRuntimeType()), JacksonJaxbJsonProvider.class.getSimpleName()); client.register(provider); HttpAuthenticationFeature httpAuthenticationFeature = elasticsearchAuthentication.getHttpAuthenticationFeature(); if (httpAuthenticationFeature != null) { client.register(httpAuthenticationFeature); } updateClients(); }
Example #5
Source File: HttpClientCommon.java From datacollector with Apache License 2.0 | 4 votes |
private void configureCompression(ClientBuilder clientBuilder) { clientBuilder.register(GZipEncoder.class); clientBuilder.register(EncodingFilter.class); }