Hello Oleg,
Thanks. But taking this example:
RequestConfig.Builder builder = RequestConfig.custom(); if (proxyPort != 0) {
builder.setProxy(new HttpHost(proxyHost, proxyPort)) } RequestConfig config
= builder.build();
The question is this can be modified once the CloseableHttpClient is already
created. This means that I had a proxy but not now, thus I want to remove this
proxy from the HttpClient.
Must I create another RequestConfig.Builder, reconfigure it with all options
(without the setProxy, because now I don't have proxy) and set it again to the
HttpClient?
Thanks,
Joan.
-----Mensaje original-----
De: Oleg Kalnichevski [mailto:[email protected]]
Enviado el: miércoles, 12 de marzo de 2014 15:35
Para: HttpClient User Discussion
Asunto: Re: Migrating from 4.1 to 4.3
On Tue, 2014-03-11 at 12:43 +0100, Joan Balagueró wrote:
> Hello,
>
....
>
>
> 1. Where can I set the manager connection timeout?
>
> HttpClientParams.setConnectionManagerTimeout(this.objHttpParams, 1);
RequestConfig config = RequestConfig.custom()
.setConnectionRequestTimeout(1)
.build();
>
> 2. Where can I set the default connection timeout?
>
> HttpConnectionParams.setConnectionTimeout(this.objHttpParams,
> connectionTimeout);
>
RequestConfig config = RequestConfig.custom()
.setConnectTimeout(n)
.build();
> 3. I see how to add a proxy to the HttpClientBuilder, but how can I
> remove it?
>
> public void setProxy(String proxyHost, int proxyPort)
>
> {
>
> if (proxyPort == 0)
> this.objHttpParams.removeParameter(ConnRoutePNames.DEFAULT_PROXY);
>
> else
> this.objHttp.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY,
> new HttpHost(proxyHost, proxyPort));
>
> }
>
RequestConfig.Builder builder = RequestConfig.custom(); if (proxyPort != 0) {
builder.setProxy(new HttpHost(proxyHost, proxyPort)) } RequestConfig config
= builder.build();
>
>
> 4. Similar, for example, a retry handler:
>
> public void setRetryHandler(int retryHttp)
>
> {
>
> if (retryHttp > 0) this.objHttp.setHttpRequestRetryHandler(new
> DefaultHttpRequestRetryHandler(retryHttp, false));
>
> else this.objHttp.setHttpRequestRetryHandler(new
> DefaultHttpRequestRetryHandler(0, false));
>
> }
>
HttpClientBuilder builder = HttpClients.custom(); if (retryHttp > 0) {
builder.setRetryHandler(new
DefaultHttpRequestRetryHandler(retryHttp, false)); } else {
builder.setRetryHandler(new DefaultHttpRequestRetryHandler(0, false)); }
CloseableHttpClient client = builder.build();
Oleg
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]