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

A request retry upon redirect is incorrectly flagged as a circular redirect

    XMLWordPrintableJSON

Details

    Description

      When a request is redirected and then needs to be retried, the retry is treated as a circular redirect. If circular redirects are not allowed, an error is thrown:

       

      org.apache.hc.client5.http.ClientProtocolException: Circular redirect to 'http://localhost:35731/random/50'    at org.apache.hc.client5.http.impl.classic.InternalHttpClient.doExecute(InternalHttpClient.java:173)
          at org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:245)
          at org.apache.hc.client5.testing.sync.TestRedirects.testRetryUponRedirect(TestRedirects.java:241)
          at java.base/java.lang.reflect.Method.invoke(Method.java:580)
          at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
          at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
          at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
      Caused by: org.apache.hc.client5.http.CircularRedirectException: Circular redirect to 'http://localhost:35731/random/50'
          at org.apache.hc.client5.http.impl.classic.RedirectExec.execute(RedirectExec.java:144)
          at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
          at org.apache.hc.client5.http.impl.classic.InternalHttpClient.doExecute(InternalHttpClient.java:170)
          ... 6 more

       

      Please see testRetryUponRedirect in TestRedirects.java for an example. NullHandler.java will return a bad response only for the first redirected request (files attached)

      Attachments

        1. TestRedirects.java
          29 kB
          Teresa Tang
        2. NullHandler.java
          5 kB
          Teresa Tang

        Activity

          People

            Unassigned Unassigned
            ttang Teresa Tang
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: