简体   繁体   English

java.net.HttpClient 上是否有任何连接池处理?

[英]Is there any handling of connection pooling on java.net.HttpClient?

I want to use Java 11 HttpClient and send multiple requests on the same address with the use of the Keep-Alive parameter of HTTP 1.1.我想使用 Java 11 HttpClient 并使用 HTTP 1.1 的 Keep-Alive 参数在同一地址上发送多个请求。 I know that there is similar functionality for Apache HTTP Client, but is there anything like that for Java API's client?我知道 Apache HTTP 客户端有类似的功能,但是 Java API 的客户端有类似的功能吗?

Yes - HTTP/1.1 connections are kept alive by default, unless the maximum size of the pool is exceeded, in which case the oldest idle connection in the pool (the connection which is closest to its expiration date) is closed to make room for the new connection.是 - HTTP/1.1 连接默认保持活动状态,除非超过池的最大大小,在这种情况下,池中最旧的空闲连接(最接近其到期日期的连接)将关闭以为新的连接。 However multiple connections to the same host will be opened if the requests are made concurrently.但是,如果同时发出请求,将打开到同一主机的多个连接。

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

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