代码拉取完成,页面将自动刷新
From 434772930f362145516dd60681134e7f0cf8115b Mon Sep 17 00:00:00 2001
From: Mark Thomas <markt@apache.org>
Date: Tue, 1 Jul 2025 19:58:55 +0100
Subject: [PATCH] Apply the initial HTTP/2 connection limits earlier.
Origin: https://github.com/apache/tomcat/commit/434772930f362145516dd60681134e7f0cf8115b
---
.../coyote/http2/ConnectionSettingsBase.java | 19 +++++++++++++++++--
.../coyote/http2/ConnectionSettingsLocal.java | 5 ++++-
.../coyote/http2/Http2UpgradeHandler.java | 8 ++++++--
3 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/java/org/apache/coyote/http2/ConnectionSettingsBase.java b/java/org/apache/coyote/http2/ConnectionSettingsBase.java
index 749fac5cff51..47141ba05018 100644
--- a/java/org/apache/coyote/http2/ConnectionSettingsBase.java
+++ b/java/org/apache/coyote/http2/ConnectionSettingsBase.java
@@ -66,6 +66,11 @@ abstract class ConnectionSettingsBase<T extends Throwable> {
final void set(Setting setting, long value) throws T {
+ set(setting, value, false);
+ }
+
+
+ final void set(Setting setting, long value, boolean force) throws T {
if (log.isTraceEnabled()) {
log.trace(sm.getString("connectionSettings.debug", connectionId, getEndpointName(), setting,
Long.toString(value)));
@@ -102,11 +107,21 @@ final void set(Setting setting, long value) throws T {
return;
}
- set(setting, Long.valueOf(value));
+ set(setting, Long.valueOf(value), force);
}
- synchronized void set(Setting setting, Long value) {
+ /**
+ * Specify a new value for setting with the option to force the change to take effect immediately rather than
+ * waiting until an {@code ACK} is received.
+ *
+ * @param setting The setting to update
+ * @param value The new value for the setting
+ * @param force {@code false} if an {@code ACK} must be received before the setting takes effect or {@code true}
+ * if the setting to take effect immediately. Even if the setting takes effect immediately, it
+ * will still be included in the next {@code SETTINGS} frame and an {@code ACK} will be expected.
+ */
+ synchronized void set(Setting setting, Long value, boolean force) {
current.put(setting, value);
}
diff --git a/java/org/apache/coyote/http2/ConnectionSettingsLocal.java b/java/org/apache/coyote/http2/ConnectionSettingsLocal.java
index 372be80223c9..5ceec8ece198 100644
--- a/java/org/apache/coyote/http2/ConnectionSettingsLocal.java
+++ b/java/org/apache/coyote/http2/ConnectionSettingsLocal.java
@@ -40,12 +40,15 @@ class ConnectionSettingsLocal extends ConnectionSettingsBase<IllegalArgumentExce
@Override
- final synchronized void set(Setting setting, Long value) {
+ final synchronized void set(Setting setting, Long value, boolean force) {
checkSend();
if (current.get(setting).longValue() == value.longValue()) {
pending.remove(setting);
} else {
pending.put(setting, value);
+ if (force) {
+ current.put(setting, value);
+ }
}
}
diff --git a/java/org/apache/coyote/http2/Http2UpgradeHandler.java b/java/org/apache/coyote/http2/Http2UpgradeHandler.java
index 51bf38923856..234dd74f8ab8 100644
--- a/java/org/apache/coyote/http2/Http2UpgradeHandler.java
+++ b/java/org/apache/coyote/http2/Http2UpgradeHandler.java
@@ -161,8 +161,12 @@ class Http2UpgradeHandler extends AbstractStream implements InternalHttpUpgradeH
remoteSettings = new ConnectionSettingsRemote(connectionId);
localSettings = new ConnectionSettingsLocal(connectionId);
- localSettings.set(Setting.MAX_CONCURRENT_STREAMS, protocol.getMaxConcurrentStreams());
- localSettings.set(Setting.INITIAL_WINDOW_SIZE, protocol.getInitialWindowSize());
+ /*
+ * Force set these initial limits. A well-behaved client should ACK the settings and adhere to them before it
+ * reaches the limits anyway.
+ */
+ localSettings.set(Setting.MAX_CONCURRENT_STREAMS, protocol.getMaxConcurrentStreams(), true);
+ localSettings.set(Setting.INITIAL_WINDOW_SIZE, protocol.getInitialWindowSize(), true);
pingManager.initiateDisabled = protocol.getInitiatePingDisabled();
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。