Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
4.2 Final
-
None
Description
The release version of HttpClient 4.2 introduces a regression with cross-site redirects that didn't exist previously.
According to Oleg Kalnichevski in HTTPCLIENT-1185: "There is unfortunately a bug in the BasicClientConnectionManager introduced in 4.2 causing issues with cross-site redirects."
For example, the following code
import java.io.IOException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
public class BadRequest {
public static void main(String[] args) {
try
catch (IOException e)
{ e.printStackTrace(); } }
}
raises an exception as follows:
% java BadRequest
org.apache.http.client.ClientProtocolException
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:909)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:784)
at BadRequest.main(BadRequest.java:13)
Caused by: org.apache.http.HttpException: Unable to establish route: planned = {}>http://edu.mah.se; current = {}>http://www.edu.mah.se
at org.apache.http.impl.client.DefaultRequestDirector.establishRoute(DefaultRequestDirector.java:842)
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:645)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:480)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
... 3 more