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

Difference in behavior between 4.5.x and 5.0.x - CloseableHttpClient returns 403 after NoHttpResponseException

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Not A Bug
    • Affects Version/s: 5.0.2
    • Fix Version/s: None
    • Labels:
      None
    • Environment:
      Microsoft Windows 10 version 2004 [10.0.19041.508]
      Oracle JDK 11.0.8

      Description

      My application reuses an instance of CloseableHttpClient to retrieve the content from a list of URLs. After upgrading HttpClient from 4.5.x to 5.0.2 (also 5.0 and 5.0.1), it always gets a NoHttpResponseException followed by a response code of 403 for a particular URL in the list.  When using 4.5.x, it always gets a 200 or 304 for that particular URL.

      The behavior may be different if the order of the URLs in the list is changed.

      To illustrate the problem, I have extracted code from my application into the sample Maven project attached. In the JUnit test, testHttpClient4() will get either 200 or 304 for all the URLs. On the other hand, testHttpClient5() always gets 403 for the last URL in the list. In this project, I intentionally added a If-Modified-Since header with the value being current time minus 1 minute so that we should get a 304 from most of the URLs.

      Can you investigate if this is really an obscure bug or an undocumented behavior change related to how CloseableHttpClient handles redirects?

      Thanks.

        Attachments

        1. all_except_wire.log
          168 kB
          Michael Lee
        2. all_except_wire.setMaxTotal5.log
          87 kB
          Michael Lee
        3. all_except_wire.setMaxTotal6.log
          98 kB
          Michael Lee
        4. demo.zip
          6 kB
          Michael Lee
        5. headers.log
          50 kB
          Michael Lee
        6. test_output.txt
          6 kB
          Michael Lee
        7. wireshark.pcapng
          1.87 MB
          Michael Lee

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              jkmlee Michael Lee
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: