You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Vicky <vi...@gmail.com> on 2014/11/14 06:49:06 UTC
Migration Queries from 4.0.1 to 4.3.5
Hi Folks,
We have are in a process of migrating our HTTP client library from 4.0.1 to
4.3.5 version. There are 2 migration areas we i have not been able to
figure out so far,
1. Dynamic adding of new Schema Registry to ClientConnectionManager. That
is, HttpClient object was already created with just HTTPS schema. But now
for a certain usecase we need to add http schema as well. We could do this
in the earlier version via the below code,
ClientConnectionManager manager = httpClient.getConnectionManager();
manager.getSchemeRegistry().register(new Scheme(HttpMethods.PROTOCOL_HTTP,
PlainSocketFactory.getSocketFactory(), 80));
But haven't been able to figure out how to do this with the newer version.
2. Dynamically adding and removing interceptors. After HttpClient object is
created for certain requests we needed to dynamically remove certain
interceptors. Example for a one case we needed to ignore/disable cookie
usage. With earlier version we could do it like below,
((DefaultHttpClient)httpClient).removeRequestInterceptorByClass(RequestAddCookies.class);
((DefaultHttpClient)httpClient).removeResponseInterceptorByClass(ResponseProcessCookies.class);
Couldn't find a way to do it in 4.3.5.
Thanks,
Vicky
Re: Migration Queries from 4.0.1 to 4.3.5
Posted by Oleg Kalnichevski <ol...@apache.org>.
On Fri, 2014-11-14 at 11:19 +0530, Vicky wrote:
> Hi Folks,
>
> We have are in a process of migrating our HTTP client library from 4.0.1 to
> 4.3.5 version. There are 2 migration areas we i have not been able to
> figure out so far,
>
> 1. Dynamic adding of new Schema Registry to ClientConnectionManager. That
> is, HttpClient object was already created with just HTTPS schema. But now
> for a certain usecase we need to add http schema as well. We could do this
> in the earlier version via the below code,
>
What is exactly the benefit of doing so?
The only way to do the same with newer APIs is to upgrade to 4.4 and to
create a custom HttpClientConnectionOperator.
> ClientConnectionManager manager = httpClient.getConnectionManager();
> manager.getSchemeRegistry().register(new Scheme(HttpMethods.PROTOCOL_HTTP,
> PlainSocketFactory.getSocketFactory(), 80));
>
> But haven't been able to figure out how to do this with the newer version.
>
> 2. Dynamically adding and removing interceptors. After HttpClient object is
> created for certain requests we needed to dynamically remove certain
> interceptors. Example for a one case we needed to ignore/disable cookie
> usage. With earlier version we could do it like below,
>
> ((DefaultHttpClient)httpClient).removeRequestInterceptorByClass(RequestAddCookies.class);
> ((DefaultHttpClient)httpClient).removeResponseInterceptorByClass(ResponseProcessCookies.class);
>
> Couldn't find a way to do it in 4.3.5.
>
The recommended way would be to add the interceptors at construction
time but use a custom flag in HttpContext to enable / disable /
customize their behavior at runtime.
Oleg
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org