简体   繁体   English

Java中用于HTTP / 1.1持久性(“ Connection:Close”)连接的最佳库是什么?

[英]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端点的库。 Http connection version is "1.1" . Http连接版本为“ 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? 1. Apache Http客户端?

2. HttpURLConnection(Standart Java Http Library)? 2. HttpURLConnection(标准Java Http库)?

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 JDK中有一个旧的HttpUrlConnection类,JDK 11中有一个新的API,它同时支持HTTP / 1.1和2。它包含一个名为java.net.http的新模块,该模块可导出同名包并在JDK11

module java.net.http {

  exports java.net.http;
}

here is a very good article on the new JDK11 API 是有关新的JDK11 API的非常好的文章

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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