hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Migrating from Commons HttpClient (3.x) to HttpComponents Client (4.x)
Date Fri, 04 May 2012 15:07:26 GMT
On Fri, 2012-05-04 at 14:28 +0300, Mugoma Joseph Okomba wrote:
> Hello,
> I would like to migrate from HttpClient 3.x to HttpClient 4.x but having
> difficulty how to handle redirects. The code works properly under Commons
> HttpClient but breaks when migrated to HttpComponents Client. Some of the
> links get undesirable redirects but when I set
> "http.protocol.handle-redirects" to 'false' I get no result altogether for
> some of the links.
> I won't want redirects but under HttpClient 4.x if I enable redirects then
> I get some that are undesirable, e.g.  http://www.walmart.com/ =>
> http://mobile.walmart.com/. Under HttpClient 3.x no such redirects
> happens.
> What do I need to do to migrate HttpClient 3.x to HttpClient 4.x without
> breaking the code?
> Thanks in advance.
> Mugoma.

(1) Redirect handling in HC 3.x is utterly and irreparably broken. HC
4.x does a much more reasonable job at handling redirects.

(2) There is no such thing as undesirable redirects from the HTTP
protocol standpoint. Redirects are either legal, illegal or legal but
requiring user intervention. If you want to handle redirects selectively
(allowing some redirects but disallowing others) you can always
implement a custom RedirectStrategy and configure HttpClient to use it
instead of the default one.


To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org

View raw message