简体   繁体   中英

What is the best library for HTTP/1.1 persistent(“Connection: Close”) connections in Java?

I must choose a library for connecting to http endpoint. Http connection version is "1.1" . Server sends data to client continuously after opening the connection. So, connection is persistent; "Connection: Close" .

For this purpose, Which library is better? Is there any benchmark of these libraries such as performance, reliability etc.?

1. Apache Http Client?

2. HttpURLConnection(Standart Java Http Library)?

there is this legacy HttpUrlConnection class in JDK, and there's a new API in JDK 11, that supports both HTTP/1.1 and 2. It contains a new module called java.net.http which exports a package of the same name and is defined in JDK11

module java.net.http {

  exports java.net.http;
}

here is a very good article on the new JDK11 API

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