简体   繁体   中英

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

关于这两个HTTP库之间的权衡,我应该知道些什么?

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM