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 ) ) {
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 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); }
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, 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, 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); }
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, 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); } }
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) { 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) { 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) { 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) { 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); }
protected ApacheHttpClient4 doCreateHttpClientFor( final ConnectionInfo connectionInfo, final XStream xstream ) { final ApacheHttpClient4Config config = new DefaultApacheHttpClient4Config(); config.getSingletons().add( new XStreamXmlProvider( xstream, APPLICATION_XML_UTF8_TYPE ) ); // set _real_ URL for baseUrl, and not a redirection (typically http instead of https) config.getProperties().put( ApacheHttpClient4Config.PROPERTY_FOLLOW_REDIRECTS, Boolean.FALSE ); config.getFeatures().put( JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE ); applyAuthenticationIfAny( connectionInfo, config ); applyProxyIfAny( connectionInfo, config ); final ApacheHttpClient4 client = ApacheHttpClient4.create( config ); // set UA client.getClientHandler().getHttpClient().getParams().setParameter( CoreProtocolPNames.USER_AGENT, "Nexus-Client/" + discoverClientVersion() ); // NXCM-4547 JERSEY-1293 Enforce proxy setting on httpclient enforceProxyUri( config, client ); if ( LOG.isDebugEnabled() ) { client.addFilter( new LoggingFilter() ); } return client; }