Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I use the java.net or org.apache.http library for HTTP in my Java application?

What should I know about the trade-offs between these two HTTP libraries?

like image 391
Steven Avatar asked Jun 09 '10 05:06

Steven


2 Answers

Depends on your needs I would say. I used the java.net one while doing simple GETs and POSTs. Suddenly I needed support for session cookies etc, and I switched to the HTTPClient.

That's also my general recommendation. Don't introduces dependencies on third-party libraries for simple tasks that can be easily done without.

like image 127
aioobe Avatar answered Sep 30 '22 10:09

aioobe


Well, the apache library is easy to use and reliable, but as aioobe said introduces external dependencies (given that has apache license that should not be a problem for commercial products). IMHO if you have to handle a lot of simultaneous connections I will go for the apache lib as the performance will be probably better.

Check this article: http://lassewesth.blogspot.com.es/2009/05/i-like-apache-http-client-over.html

like image 21
PakitoV Avatar answered Sep 30 '22 11:09

PakitoV