HttpComponents HttpClient
  1. HttpComponents HttpClient
  2. HTTPCLIENT-1193

Regression causing issues with cross-site redirects

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 4.2 Final
    • Fix Version/s: 4.2.1
    • Component/s: HttpClient
    • Labels:
      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

      { HttpClient httpclient = new DefaultHttpClient(); HttpGet httpget = new HttpGet("http://www.edu.mah.se/KK3231/syllabus/"); System.out.println(httpclient.execute(httpget).getStatusLine().getStatusCode()); }

      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

        Activity

          People

          • Assignee:
            Unassigned
            Reporter:
            Magnus Gustavsson
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development