ApacheDockerHttpClient builder support customize httpclient's RequestConfig and PoolingHttpClientConnectionManager
See original GitHub issueHi guys, I am using docker-java to implement my business, I love this library and I found I cannot cusomize ApacheDockerHttpClient’ HttpClient request configs. I am initializing ApacheDockerHttpClient instance with this code:
return new ApacheDockerHttpClient.Builder()
.dockerHost(dockerClientConfig.getDockerHost())
.sslConfig(dockerClientConfig.getSSLConfig())
.build();
I have view the source code, and may be you guys can change the ApacheDockerHttpClientImpl scope to support caller change httpClient
properties?
Just return HttpClientBuilder instead HttpClient will be more flexiable
httpClient = HttpClients.custom()
.setRequestExecutor(new HijackingHttpRequestExecutor(null))
.setConnectionManager(new PoolingHttpClientConnectionManager(
socketFactoryRegistry,
new ManagedHttpClientConnectionFactory(
null,
null,
null,
null,
message -> {
Header transferEncodingHeader = message.getFirstHeader(HttpHeaders.TRANSFER_ENCODING);
if (transferEncodingHeader != null) {
if ("identity".equalsIgnoreCase(transferEncodingHeader.getValue())) {
return ContentLengthStrategy.UNDEFINED;
}
}
return DefaultContentLengthStrategy.INSTANCE.determineLength(message);
},
null
)
))
.build();
Thanks
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Apache HttpClient Connection Management - Baeldung
The PoolingHttpClientConnectionManager will create and manage a pool of connections for each route or target host we use. The default size of ...
Read more >RequestConfig.Builder (Apache HttpClient 5.2.1 API)
Determines the order of preference for supported authentication schemes by their names when authenticating with the target host. Methods inherited from class ...
Read more >RequestConfig.Builder (Apache HttpClient 4.5.8 API)
Object extended by org.apache.http.client.config.RequestConfig.Builder ... Builder; extends Object ... (4.4) Use PoolingHttpClientConnectionManager.
Read more >org.apache.http.client.config.RequestConfig.custom java code ...
builder.setMaxConnPerRoute(50); builder.setMaxConnTotal(100); CloseableHttpClient httpclient = builder.build(); URI uri = new URIBuilder(url).build(); ...
Read more >How to write tests on HTTP client apache? - Stack Overflow
Javalin would be an excellent tool for mocking the real service as it allows for state assertions in your tests.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @bsideup
Thanks for your answer.
I want to change the default max connections per route property in PoolingHttpClientConnectionManager class, I have used httpclient in other business service, I noticed that in PoolingHttpClientConnectionManager source code
I want customize these parameters to fit different machine’s performance.
And the
HttpClients.custom().build()
method using default RequestConfig with these parameters:The default timeout for my business is not very suitable, I want to decrease the connectTimeout
why closed?