httpClient.setMaxRequestsQueuedPerDestination(config.getNumRequestsQueued()); httpClient.setConnectTimeout(CLIENT_CONNECT_TIMEOUT_MILLIS); httpClient.setRequestBufferSize(config.getRequestBuffersize());
@Provides @Singleton public HttpClient provideHttpClient(ExecutorService executorService, @Named("httpClient.maxConnectionsQueued") Integer maxConnectionsQueued, @Named("httpClient.maxConnectionPerRoute") Integer maxConnectionPerRoute, @Named("httpClient.requestBufferSize") Integer requestBufferSize, @Named("httpClient.responseBufferSize") Integer responseBufferSize, @Named("httpClient.maxRedirects") Integer maxRedirects, @Named("httpClient.trustAllCertificates") Boolean trustAllCertificates) { try { SslContextFactory sslContextFactory = new SslContextFactory(); sslContextFactory.setTrustAll(trustAllCertificates); HttpClient httpClient = new HttpClient(sslContextFactory); httpClient.setExecutor(executorService); httpClient.setMaxConnectionsPerDestination(maxConnectionsQueued); httpClient.setMaxRequestsQueuedPerDestination(maxConnectionPerRoute); httpClient.setRequestBufferSize(requestBufferSize); httpClient.setResponseBufferSize(responseBufferSize); httpClient.setMaxRedirects(maxRedirects); httpClient.start(); registerHttpClientShutdownHook(httpClient); return httpClient; } catch (Exception e) { System.out.println(Arrays.toString(e.getStackTrace())); throw new RuntimeException(e.getLocalizedMessage(), e); } }
private HttpClient client() { HttpField agent = new HttpField("User-Agent", config.agent); HttpClient httpClient = new HttpClient(); httpClient.setFollowRedirects(false); httpClient.setMaxConnectionsPerDestination(MAX_CONNECTIONS_PER_DEST); httpClient.setMaxRequestsQueuedPerDestination(MAX_QUEUED_REQUESTS_PER_DEST); httpClient.setUserAgentField(agent); httpClient.setCookieStore(new HttpCookieStore.Empty()); return httpClient; }
private HttpClient client() { HttpField agent = new HttpField("User-Agent", config.agent); // TODO: non-keepalived client connections HttpClient httpClient = new HttpClient(); httpClient.setFollowRedirects(false); httpClient.setMaxConnectionsPerDestination(MAX_CONNECTIONS_PER_DEST); httpClient.setMaxRequestsQueuedPerDestination(MAX_QUEUED_REQUESTS_PER_DEST); httpClient.setUserAgentField(agent); httpClient.setCookieStore(new HttpCookieStore.Empty()); return httpClient; }
httpClient.setMaxRequestsQueuedPerDestination(config.getNumRequestsQueued()); httpClient.setConnectTimeout(CLIENT_CONNECT_TIMEOUT); httpClient.setRequestBufferSize(config.getRequestBuffersize());
httpClient.setMaxRequestsQueuedPerDestination(config.getNumRequestsQueued()); httpClient.setConnectTimeout(CLIENT_CONNECT_TIMEOUT_MILLIS); httpClient.setRequestBufferSize(config.getRequestBuffersize());
@Override protected void configureClient() { boolean addSslSupport = StringUtils.isNotEmpty(metadata.getKeyStorePath()) && StringUtils.isNotEmpty(metadata.getKeyStorePassword()); if(addSslSupport){ SslContextFactory sslContextFactory = new SslContextFactory(); sslContextFactory.setKeyStorePath(metadata.getKeyStorePath()); sslContextFactory.setKeyStorePassword(metadata.getKeyStorePassword()); boolean addTrustSupport = StringUtils.isNotEmpty(metadata.getTrustStorePath()) && StringUtils.isNotEmpty(metadata.getTrustStorePassword()); if(addTrustSupport){ sslContextFactory.setTrustStorePath(metadata.getTrustStorePath()); sslContextFactory.setTrustStorePassword(metadata.getTrustStorePassword()); }else{ sslContextFactory.setTrustAll(true); } httpClient = new HttpClient(sslContextFactory); } httpClient.setConnectTimeout(metadata.getConnectTimeout()); httpClient.setIdleTimeout(metadata.getIdleTimeout()); httpClient.setMaxConnectionsPerDestination(metadata.getMaxConnectionsPerAddress()); httpClient.setMaxRequestsQueuedPerDestination(metadata.getMaxQueueSizePerAddress()); httpClient.setFollowRedirects(followRedirects); try { httpClient.start(); } catch (Exception e) { throw new ClientException("failed to start jetty http client: " + e, e); } }
public HttpClient createClientForHttp2() { ExecutorService executor = executorFactory.getExecutorService("jetty-http2-client", configFactory.getIntProperty(CONSUMER_HTTP2_CLIENT_THREAD_POOL_SIZE), configFactory.getBooleanProperty(CONSUMER_HTTP2_CLIENT_THREAD_POOL_MONITORING)); HTTP2Client h2Client = new HTTP2Client(); h2Client.setExecutor(executor); HttpClientTransportOverHTTP2 transport = new HttpClientTransportOverHTTP2(h2Client); HttpClient client = new HttpClient(transport, createSslContextFactory()); client.setMaxRequestsQueuedPerDestination(configFactory.getIntProperty(CONSUMER_INFLIGHT_SIZE)); client.setCookieStore(new HttpCookieStore.Empty()); return client; }
public HttpClient createClientForHttp1(String name) { ExecutorService executor = executorFactory.getExecutorService(name, configFactory.getIntProperty(CONSUMER_HTTP_CLIENT_THREAD_POOL_SIZE), configFactory.getBooleanProperty(CONSUMER_HTTP_CLIENT_THREAD_POOL_MONITORING)); HttpClient client = new HttpClient(createSslContextFactory()); client.setMaxConnectionsPerDestination(configFactory.getIntProperty(CONSUMER_HTTP_CLIENT_MAX_CONNECTIONS_PER_DESTINATION)); client.setMaxRequestsQueuedPerDestination(configFactory.getIntProperty(CONSUMER_INFLIGHT_SIZE)); client.setExecutor(executor); client.setCookieStore(new HttpCookieStore.Empty()); return client; }
public HttpClient createClientForHttp2() { ExecutorService executor = executorFactory.getExecutorService("jetty-http2-client", configFactory.getIntProperty(CONSUMER_HTTP2_CLIENT_THREAD_POOL_SIZE), configFactory.getBooleanProperty(CONSUMER_HTTP2_CLIENT_THREAD_POOL_MONITORING)); HTTP2Client h2Client = new HTTP2Client(); h2Client.setExecutor(executor); HttpClientTransportOverHTTP2 transport = new HttpClientTransportOverHTTP2(h2Client); HttpClient client = new HttpClient(transport, createSslContextFactory()); client.setMaxRequestsQueuedPerDestination(configFactory.getIntProperty(CONSUMER_INFLIGHT_SIZE)); client.setCookieStore(new HttpCookieStore.Empty()); return client; }
public HttpClient createClientForHttp1(String name) { ExecutorService executor = executorFactory.getExecutorService(name, configFactory.getIntProperty(CONSUMER_HTTP_CLIENT_THREAD_POOL_SIZE), configFactory.getBooleanProperty(CONSUMER_HTTP_CLIENT_THREAD_POOL_MONITORING)); HttpClient client = new HttpClient(createSslContextFactory()); client.setMaxConnectionsPerDestination(configFactory.getIntProperty(CONSUMER_HTTP_CLIENT_MAX_CONNECTIONS_PER_DESTINATION)); client.setMaxRequestsQueuedPerDestination(configFactory.getIntProperty(CONSUMER_INFLIGHT_SIZE)); client.setExecutor(executor); client.setCookieStore(new HttpCookieStore.Empty()); return client; }
this.httpClient.setAddressResolutionTimeout(options.getIntProperty("addressResolutionTimeout", 15000)); this.httpClient.setMaxRedirects(options.getIntProperty("maxRedirects", 8)); this.httpClient.setMaxRequestsQueuedPerDestination(options.getIntProperty("maxRequestsQueuedPerDestination", 1024)); } else { SslContextFactory sslContextFactory = new SslContextFactory();
httpClient.setMaxRequestsQueuedPerDestination(config.getMaxRequestsQueuedPerDestination());
httpClient.setResponseBufferSize(toIntExact(config.getResponseBufferSize().toBytes())); httpClient.setMaxRequestsQueuedPerDestination(config.getMaxRequestsQueuedPerDestination()); httpClient.setMaxConnectionsPerDestination(config.getMaxConnectionsPerServer());