what the relationship between commons-httpclient and httpclient, both from apache

19,176

Solution 1

Commons HttpClient is an old project that produced HttpClient 3.1. The project was subsumed by the larger Apache HttpComponents project, which produced HttpClient 4.x.

It's rather confusing and a bit political, but the old Commons HttpClient library is now deprecated.

Solution 2

Any ... difference between those two libraries.

Yes. They are very different. The package names are different for a start, and the 4.x APIs are much richer than the 3.x APIs.

For a start the 4.x HttpClient APIs are based on core libraries that are designed to support both the client and server sides of HTTP. The core is designed to support both blocking I/O and event driven I/O, and there is an AsyncHttpClient API top support the latter. The framework also has a lot in the way of cookie management, connection management, client-side authentication, proxy routing, resource handling and streaming, etc.

Sadly, this all means that code that was built to use HttpClient 3.x would need a major rewrite to use HttpClient 4.x. I guess this is the source of the confusion and politics that @skaffman alludes to.

But for me, the bottom line is that if you are developing new project, you should be using HttpClient 4.x.

Share:
19,176
user496949
Author by

user496949

Updated on June 16, 2022

Comments

  • user496949
    user496949 almost 2 years

    Any relationship or difference between those two libraries.

  • skaffman
    skaffman about 13 years
    I rather prefer the 3.x API. The 4.x API I find confusing and baroque, and requires an inordinate amount of config to do the simplest things.
  • ok2c
    ok2c about 13 years
    There was nothing political about deprecation of Commons HttpClient 3.x. The simple fact is that no one, just no one, was willing to maintain it and work on that horrid mess that were 3.x core classes.
  • ok2c
    ok2c about 13 years
    @skaffman. HttpClient is being used by a great variety of different applications with different, often conflicting, requirements: web crawlers, HTTP load tools, web application testers, web service transports, HTTP proxies, gateways and others. It is non-trivial to create a common API that suits all those application domains and is simple and flexible at the same time. In the course of 4.x API development flexibility, modularity and performance were often favoured over simplicity and compatibility with 3.x code line.
  • ok2c
    ok2c about 13 years
    > "... requires an inordinate amount of config to do the simplest things." I do not think this statement is true.
  • skaffman
    skaffman about 13 years
    @oleg: Absolutely... I'm not complaining about the 4.x API per se, just that for what I use it for, 3.1 is simpler.
  • skaffman
    skaffman about 13 years
    @oleg: Fair enough :) It only looked political from when I dipped into the mailing lists early on in the 4.x dev process.
  • ok2c
    ok2c about 13 years
    Graduation into a TLP (top level project), which was mostly driven by the ASF's decision to dissolve the Jakarta project, was indeed political. There was nothing political about the decision that 2.x / 3.x API was a dead end. It was basically obvious to anyone who ever touched core classes in the 2.x and 3.x code lines.
  • ok2c
    ok2c about 13 years
    @skaffman: I will contend that everything that HC 3.1 can do, HC 4.1 can do much better. Simplicity, though, is subjective, so there is no point arguing about that.
  • Kiran M N
    Kiran M N over 11 years
    @oleg, What about the performance fine tuning with HC 4.1. Some components of our code base were built using HC 3.1, and it seems to be snappier in actually doing a HTTP Get/Post call, when compared to HC 4.1. Am trying to optimize my code (which uses HC 4.1), but am yet to come closer to that snappiness. Not sure if HC 3.1 itself was faster; or, that developer did extra stuff to optimize. I am following the good practices generally outlined - like reusing the connection etc. But, still....
  • Stephen C
    Stephen C about 11 years
    @KiranMN - "it seems to be snappier" is hardly an objective measure of performance.
  • Ravi
    Ravi almost 6 years
    I am surprised to see the results for httpclient3.x and httpclient4.x[source atlassian.com/blog/archives/http-client-performance-io]. If it is true then why the performance is slower in 4.x as compared to 3.x. and why they have not taken the pain to improve the performance
  • Ravi
    Ravi almost 6 years
    If any one have other benchmarking link, or don't agree with this please confirm[atlassian.com/blog/archives/http-client-performance-‌​io]