Spring Framework
  1. Spring Framework
  2. SPR-6180

Upgrade Apache HttpClient to version 4.0

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.0 RC1
    • Fix Version/s: 3.1 M2
    • Component/s: Web
    • Labels:
      None
    • Last commented by a User:
      false

      Description

      Folks,

      Please consider upgrading HttpClient to version 4.0 which is the latest stable (GA) version of the library. Commons HttpClient 3.1 is very likely to be deprecated / officially declared end of life very soon (3 - 6 months). There have been no bug fixes in the 3.x branch for over a year.

      Patch attached. Unfortunately I was unable to fix the Ivy build which I am not very familiar with.

      Oleg

        Issue Links

          Activity

          Hide
          Oleg Kalnichevski added a comment -

          Looks good to me. I wish there was a way to avoid having to buffer request content in memory, though.

          Oleg

          Show
          Oleg Kalnichevski added a comment - Looks good to me. I wish there was a way to avoid having to buffer request content in memory, though. Oleg
          Hide
          David Parks added a comment -

          Not sure if I should comment here or open a new request, but I'll note here first: Any use cases which require an HttpContext attribute to be set aren't covered in this implementation, and the extensions required make the whole thing so messy as to make using the Rest Template more of a burden than a benefit. Here is the particular case that I've been fussing with today to little avail, setting preemptive authentication (i.e. send basic authentication headers by default rather than performing 2 requests to authenticate):

          http://hc.apache.org/httpcomponents-client-ga/tutorial/html/authentication.html#d4e1023

          The problem being that the RestTemplate implementation as it is has no support for setting HttpContext parameters (the template calls the Http.execute(HttpUriRequest) which uses only the non-accessible default HttpContext), there aren't any good way to set the default context parameters on the HttpClient in 4.x Apache HTTP Components. You end up needing to extend HttpClient to provide for default HttpContext params on the HttpClient object and the whole thing just becomes a spaghetti mess from there making the template more pain than pleasure.

          Show
          David Parks added a comment - Not sure if I should comment here or open a new request, but I'll note here first: Any use cases which require an HttpContext attribute to be set aren't covered in this implementation, and the extensions required make the whole thing so messy as to make using the Rest Template more of a burden than a benefit. Here is the particular case that I've been fussing with today to little avail, setting preemptive authentication (i.e. send basic authentication headers by default rather than performing 2 requests to authenticate): http://hc.apache.org/httpcomponents-client-ga/tutorial/html/authentication.html#d4e1023 The problem being that the RestTemplate implementation as it is has no support for setting HttpContext parameters (the template calls the Http.execute(HttpUriRequest) which uses only the non-accessible default HttpContext), there aren't any good way to set the default context parameters on the HttpClient in 4.x Apache HTTP Components. You end up needing to extend HttpClient to provide for default HttpContext params on the HttpClient object and the whole thing just becomes a spaghetti mess from there making the template more pain than pleasure.
          Hide
          Arjen Poutsma added a comment -

          @David

          That's certainly something we can try to improve. Can you please create a new JIRA for this issue, and comment the issue number here so that I can follow up on it?

          Show
          Arjen Poutsma added a comment - @David That's certainly something we can try to improve. Can you please create a new JIRA for this issue, and comment the issue number here so that I can follow up on it?
          Hide
          David Parks added a comment -
          Show
          David Parks added a comment - Added: https://jira.springsource.org/browse/SPR-8367
          Hide
          Arjen Poutsma added a comment -

          I wish there was a way to avoid having to buffer request content in memory, though.

          There now is, see SPR-10728.

          Show
          Arjen Poutsma added a comment - I wish there was a way to avoid having to buffer request content in memory, though. There now is, see SPR-10728 .

            People

            • Assignee:
              Arjen Poutsma
              Reporter:
              Oleg Kalnichevski
              Last updater:
              Arjen Poutsma
            • Votes:
              17 Vote for this issue
              Watchers:
              20 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                40 weeks, 1 day ago

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0d
                0d
                Logged:
                Time Spent - 6.25h
                6.25h