private JerseyEurekaHttpClientFactory buildExperimental(Map<String, String> additionalHeaders) { ThreadSafeClientConnManager cm = createConnectionManager(); ClientConfig clientConfig = new DefaultApacheHttpClient4Config(); if (proxyHost != null) { addProxyConfiguration(clientConfig); } DiscoveryJerseyProvider discoveryJerseyProvider = new DiscoveryJerseyProvider(encoderWrapper, decoderWrapper); clientConfig.getSingletons().add(discoveryJerseyProvider); // Common properties to all clients cm.setDefaultMaxPerRoute(maxConnectionsPerHost); cm.setMaxTotal(maxTotalConnections); clientConfig.getProperties().put(ApacheHttpClient4Config.PROPERTY_CONNECTION_MANAGER, cm); String fullUserAgentName = (userAgent == null ? clientName : userAgent) + "/v" + buildVersion(); clientConfig.getProperties().put(CoreProtocolPNames.USER_AGENT, fullUserAgentName); // To pin a client to specific server in case redirect happens, we handle redirects directly // (see DiscoveryClient.makeRemoteCall methods). clientConfig.getProperties().put(ClientConfig.PROPERTY_FOLLOW_REDIRECTS, Boolean.FALSE); clientConfig.getProperties().put(ClientPNames.HANDLE_REDIRECTS, Boolean.FALSE); ApacheHttpClient4 apacheClient = ApacheHttpClient4.create(clientConfig); addFilters(apacheClient); return new JerseyEurekaHttpClientFactory(apacheClient, connectionIdleTimeout, additionalHeaders); }
private void setConfig() throws KettleException { if ( data.config == null ) { data.config = new DefaultApacheHttpClient4Config(); if ( !Utils.isEmpty( data.realProxyHost ) ) { data.config.getProperties().put( ApacheHttpClient4Config.PROPERTY_PROXY_URI, "http://" + data.realProxyHost + ":" + data.realProxyPort ); if ( !Utils.isEmpty( data.realHttpLogin ) && !Utils.isEmpty( data.realHttpPassword ) ) { AuthScope authScope = new AuthScope( data.realProxyHost, data.realProxyPort ); CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); credentialsProvider.setCredentials( authScope, credentials ); data.config.getProperties().put( ApacheHttpClient4Config.PROPERTY_CREDENTIALS_PROVIDER, credentialsProvider ); data.config.getProperties().put( ApacheHttpClient4Config.PROPERTY_PREEMPTIVE_BASIC_AUTHENTICATION, true ); data.config.getProperties().put( HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, new HTTPSProperties( hv, ctx ) ); } catch ( NoSuchAlgorithmException e ) { throw new KettleException( BaseMessages.getString( PKG, "Rest.Error.NoSuchAlgorithm" ), e );
private ApacheHttpClient4Config buildConfig(ObjectMapper objectMapper) { final ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config(); config.getSingletons().addAll(singletons); config.getSingletons().add(new JacksonMessageBodyProvider(objectMapper, new Validator())); config.getClasses().addAll(providers); config.getFeatures().putAll(features); config.getProperties().putAll(properties); return config; } }
private static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration, MetricRegistry metricRegistry, String serviceName) { HttpClient httpClient = new HttpClientBuilder(metricRegistry).using(configuration).build(serviceName); ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true); ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config(); config.getSingletons().add(new JacksonMessageBodyProvider(Jackson.newObjectMapper(), _validatorFactory.getValidator())); return new ApacheHttpClient4(handler, config); }
@Override public void initWithNiwsConfig(IClientConfig clientConfig) { super.initWithNiwsConfig(clientConfig); this.ncc = clientConfig; this.restClientName = ncc.getClientName(); this.isSecure = getBooleanFromConfig(ncc, CommonClientConfigKey.IsSecure, this.isSecure); this.isHostnameValidationRequired = getBooleanFromConfig(ncc, CommonClientConfigKey.IsHostnameValidationRequired, this.isHostnameValidationRequired); this.isClientAuthRequired = getBooleanFromConfig(ncc, CommonClientConfigKey.IsClientAuthRequired, this.isClientAuthRequired); this.bFollowRedirects = getBooleanFromConfig(ncc, CommonClientConfigKey.FollowRedirects, true); this.ignoreUserToken = getBooleanFromConfig(ncc, CommonClientConfigKey.IgnoreUserTokenInConnectionPoolForSecureClient, this.ignoreUserToken); this.config = new DefaultApacheHttpClient4Config(); this.config.getProperties().put( ApacheHttpClient4Config.PROPERTY_CONNECT_TIMEOUT, Integer.parseInt(String.valueOf(ncc.getProperty(CommonClientConfigKey.ConnectTimeout)))); this.config.getProperties().put( ApacheHttpClient4Config.PROPERTY_READ_TIMEOUT, Integer.parseInt(String.valueOf(ncc.getProperty(CommonClientConfigKey.ReadTimeout)))); this.restClient = apacheHttpClientSpecificInitialization(); this.setRetryHandler(new HttpClientLoadBalancerErrorHandler(ncc)); }
private static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration, String serviceName, MetricRegistry metricRegistry) { HttpClient httpClient = new HttpClientBuilder(metricRegistry).using(configuration).build(serviceName); ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true); ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config(); config.getSingletons().add(new JacksonMessageBodyProvider(Jackson.newObjectMapper(), _validatorFactory.getValidator())); return new ApacheHttpClient4(handler, config); }
private static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration) { HttpClient httpClient = new HttpClientBuilder().using(configuration).build(); ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true); ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config(); // For shading reasons we can't add a Jackson JSON message body provider. However, our client implementation will // handle wrapping all request and response entities using the shaded Jackson so this shouldn't matter. return new ApacheHttpClient4(handler, config); }
DefaultApacheHttpClient4Config config = new DefaultApacheHttpClient4Config(); config.getProperties().put( ApacheHttpClient4Config.PROPERTY_PROXY_URI, "PROXY_URL" ); config.getProperties().put( ApacheHttpClient4Config.PROPERTY_PROXY_USERNAME, "PROXY_USER" ); config.getProperties().put( ApacheHttpClient4Config.PROPERTY_PROXY_PASSWORD, "PROXY_PASS" ); Client c = ApacheHttpClient4.create(config); WebResource r = c.resource("https://www.google.com/");
private static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration, MetricRegistry metricRegistry, String serviceName) { HttpClient httpClient = new HttpClientBuilder(metricRegistry).using(configuration).build(serviceName); ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true); ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config(); config.getSingletons().add(new JacksonMessageBodyProvider(Jackson.newObjectMapper(), _validatorFactory.getValidator())); return new ApacheHttpClient4(handler, config); } }
private static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration) { HttpClient httpClient = new HttpClientBuilder().using(configuration).build(); ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true); ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config(); // For shading reasons we can't add a Jackson JSON message body provider. However, our client implementation will // handle wrapping all request and response entities using the shaded Jackson so this shouldn't matter. return new ApacheHttpClient4(handler, config); }
static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration, String serviceName, MetricRegistry metricRegistry) { HttpClient httpClient = new HttpClientBuilder(metricRegistry).using(configuration).build(serviceName); ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true); ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config(); config.getSingletons().add(new JacksonMessageBodyProvider(Jackson.newObjectMapper(), _validatorFactory.getValidator())); return new ApacheHttpClient4(handler, config); }
private static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration) { HttpClient httpClient = new HttpClientBuilder().using(configuration).build(); ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true); ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config(); // For shading reasons we can't add a Jackson JSON message body provider. However, our client implementation will // handle wrapping all request and response entities using the shaded Jackson so this shouldn't matter. return new ApacheHttpClient4(handler, config); }
private static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration, MetricRegistry metricRegistry, String serviceName) { HttpClient httpClient = new HttpClientBuilder(metricRegistry).using(configuration).build(serviceName); ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true); ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config(); config.getSingletons().add(new JacksonMessageBodyProvider(Jackson.newObjectMapper(), _validatorFactory.getValidator())); return new ApacheHttpClient4(handler, config); }
private static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration) { HttpClient httpClient = new HttpClientBuilder().using(configuration).build(); ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true); ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config(); // For shading reasons we can't add a Jackson JSON message body provider. However, our client implementation will // handle wrapping all request and response entities using the shaded Jackson so this shouldn't matter. return new ApacheHttpClient4(handler, config); }
private static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration, String serviceName, MetricRegistry metricRegistry) { HttpClient httpClient = new HttpClientBuilder(metricRegistry).using(configuration).build(serviceName); ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true); ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config(); config.getSingletons().add(new JacksonMessageBodyProvider(Jackson.newObjectMapper(), _validatorFactory.getValidator())); return new ApacheHttpClient4(handler, config); }
private static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration) { HttpClient httpClient = new HttpClientBuilder().using(configuration).build(); ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true); ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config(); // For shading reasons we can't add a Jackson JSON message body provider. However, our client implementation will // handle wrapping all request and response entities using the shaded Jackson so this shouldn't matter. return new ApacheHttpClient4(handler, config); }
private static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration, String serviceName, MetricRegistry metricRegistry) { HttpClient httpClient = new HttpClientBuilder(metricRegistry).using(configuration).build(serviceName); ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true); ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config(); config.getSingletons().add(new JacksonMessageBodyProvider(Jackson.newObjectMapper(), _validatorFactory.getValidator())); return new ApacheHttpClient4(handler, config); }
private static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration, MetricRegistry metricRegistry, String serviceName) { HttpClient httpClient = new HttpClientBuilder(metricRegistry).using(configuration).build(serviceName); ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true); ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config(); config.getSingletons().add(new JacksonMessageBodyProvider(Jackson.newObjectMapper(), _validatorFactory.getValidator())); return new ApacheHttpClient4(handler, config); }
private static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration, MetricRegistry metricRegistry, String serviceName) { HttpClient httpClient = new HttpClientBuilder(metricRegistry).using(configuration).build(serviceName); ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true); ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config(); config.getSingletons().add(new JacksonMessageBodyProvider(Jackson.newObjectMapper(), _validatorFactory.getValidator())); return new ApacheHttpClient4(handler, config); }
static ApacheHttpClient4 createDefaultJerseyClient(HttpClientConfiguration configuration, String serviceName, MetricRegistry metricRegistry) { HttpClient httpClient = new HttpClientBuilder(metricRegistry).using(configuration).build(serviceName); ApacheHttpClient4Handler handler = new ApacheHttpClient4Handler(httpClient, null, true); ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config(); config.getSingletons().add(new JacksonMessageBodyProvider(Jackson.newObjectMapper(), _validatorFactory.getValidator())); return new ApacheHttpClient4(handler, config); } }