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 );
/** * Creates an authentificiated REST client * * @param userName * @param password * @return A newly created client. */ public static Client createRESTClient(String userName, String password) { DefaultApacheHttpClient4Config rc = new DefaultApacheHttpClient4Config(); rc.getClasses().add(SaltProjectProvider.class); ThreadSafeClientConnManager clientConnMgr = new ThreadSafeClientConnManager(); clientConnMgr.setDefaultMaxPerRoute(10); rc.getProperties().put(ApacheHttpClient4Config.PROPERTY_CONNECTION_MANAGER, clientConnMgr); if (userName != null && password != null) { CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(userName, password)); rc.getProperties().put( ApacheHttpClient4Config.PROPERTY_CREDENTIALS_PROVIDER, credentialsProvider); rc.getProperties().put( ApacheHttpClient4Config.PROPERTY_PREEMPTIVE_BASIC_AUTHENTICATION, true); } Client c = ApacheHttpClient4.create(rc); return c; }
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; } }
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); }
DefaultApacheHttpClient4Config config = new DefaultApacheHttpClient4Config(); Map<String, Object> configProps = config.getProperties(); configProps .put(ApacheHttpClient4Config.PROPERTY_PREEMPTIVE_BASIC_AUTHENTICATION,
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); }