Uploaded image for project: 'HttpComponents HttpClient'
  1. HttpComponents HttpClient
  2. HTTPCLIENT-1197

Redirects (301 responses) to other sites (not a different page on the same site) don't get followed.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 4.2 Final
    • 4.2.1
    • None
    • None

    Description

      If a server, during a simple GET, returns http status code 301 to redirect the client to another site, an exception is thrown instead of following the new location. This is a major regression, since in httpclient 4.1 it was working correctly.

      === BugTest.java ===

      import org.apache.http.client.methods.HttpGet;
      import org.apache.http.impl.client.DefaultHttpClient;

      public class BugTest {

      public static void main(String[] args) throws Exception

      { DefaultHttpClient client = new DefaultHttpClient(); HttpGet method = new HttpGet("http://www.mvzt.gov.si/fileadmin/mvzt.gov.si/pageuploads/pdf/informacijska_druzba/SI_TL.xml"); client.execute(method); }

      }

      === BugTest.java ===

      % java BugTest
      Exception in thread "main" 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 BugTest.main(BugTest.java:9)
      Caused by: org.apache.http.HttpException: Unable to establish route: planned = {}>http://www.arhiv.mvzt.gov.si; current = {}>http://www.mvzt.gov.si
      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)

      Attachments

        Activity

          People

            Unassigned Unassigned
            alexdupre Alex Dupre
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: