Skip to content
This repository was archived by the owner on May 8, 2026. It is now read-only.

Commit d98bffe

Browse files
authored
Ignore unknown Http3Setting Identifier in Http3SettingsFrame (#360)
* According to the spec https://www.rfc-editor.org/rfc/rfc9114.html#section-7.2.4-9 , endpoints **must ignore unknown settings identifiers**. Netty’s previous behavior incorrectly **stored** unknown settings values, which contradicts RFC behaviour. * A **HTTP/3 error code** was missing - H3_DATAGRAM_ERROR * The **SETTINGS_H3_DATAGRAM (0x33)** identifier was not added. * Prior behaviour fixed in [https://github.com/netty/netty/pull/15835](https://github.com/netty/netty/pull/15835) still allowed direct injection of unsupported settings; this PR effectively deprecates that direct-settings behaviour completely. --- * [x] **Ignore unknown HTTP/3 SETTINGS identifiers** * Updated parsing logic to skip unknown settings identifiers: ```java // When Non-Standard/Unknown settings identifier present - Ignore if (Http3SettingIdentifier.fromId(key) == null) { return value; } ``` * Unknown settings are **no longer stored** in `Http3Settings`. * Fully aligns with HTTP/3 specification behaviour. * Effectively **deprecates the old direct-settings behavior** introduced/fixed in PR #15835. * [x] **Added missing HTTP/3 error codes** * Implemented the remaining H3 error codes defined in the RFC. * Ensures accurate error propagation and complete protocol support. * [x] **Added `SETTINGS_H3_DATAGRAM (0x33)`** * Introduced the identifier: ```java SETTINGS_H3_DATAGRAM(0x33) ``` * Added proper handling in both encoder and decoder paths. * [x] **Added unit tests** * Tests covering: * Ignoring unknown setting identifiers * Correct handling of `SETTINGS_H3_DATAGRAM` * Verification of newly added error codes * Ensuring unknown settings do **not** appear in `Http3Settings` --- * [x] Netty now **correctly ignores unknown HTTP/3 settings**, as required by the specification. * [x] `Http3Settings` no longer stores invalid or non-standard identifiers. * [x] Full support for **`SETTINGS_H3_DATAGRAM (0x33)`**. * [x] Complete coverage of **HTTP/3 error codes**. * [x] Added unit tests ensure long-term correctness. * [x] Behaviour from PR #15835 is effectively superseded and corrected. Fixes #[15908](netty/netty#15908) Port of netty/netty#15909
1 parent b080b82 commit d98bffe

7 files changed

Lines changed: 265 additions & 71 deletions

File tree

src/main/java/io/netty/incubator/codec/http3/Http3ErrorCode.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,20 @@
1616
package io.netty.incubator.codec.http3;
1717

1818
/**
19-
* Different <a href="https://tools.ietf.org/html/draft-ietf-quic-http-32#section-8.1">HTTP3 error codes</a>.
19+
* Different <a href="https://datatracker.ietf.org/doc/html/rfc9114#name-http-3-error-codes">HTTP3 error codes</a>.
2020
*/
2121
public enum Http3ErrorCode {
2222

23+
/**
24+
* Datagram or Capsule Protocol parse error
25+
* <a href="https://www.rfc-editor.org/rfc/rfc9297.html#name-http-3-error-code">rfc9297</a>
26+
* registered in IANA http3
27+
* <a href="https://www.iana.org/assignments/http3-parameters/http3-parameters.xhtml#http3-parameters-error-codes"
28+
* >
29+
* IANA Http3 Error Codes</a>
30+
*/
31+
H3_DATAGRAM_ERROR(0x33),
32+
2333
/**
2434
* No error. This is used when the connection or stream needs to be closed, but there is no error to signal.
2535
*/
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
/*
2+
* Copyright 2025 The Netty Project
3+
*
4+
* The Netty Project licenses this file to you under the Apache License,
5+
* version 2.0 (the "License"); you may not use this file except in compliance
6+
* with the License. You may obtain a copy of the License at:
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
package io.netty.incubator.codec.http3;
17+
18+
import org.jetbrains.annotations.Nullable;
19+
20+
import java.util.Arrays;
21+
import java.util.Collections;
22+
import java.util.Map;
23+
import java.util.function.Function;
24+
import java.util.stream.Collectors;
25+
26+
public enum Http3SettingIdentifier {
27+
28+
/**
29+
* QPACK maximum table capacity setting identifier (<b>0x1</b>).
30+
* <p>
31+
* Defined in <a href="https://datatracker.ietf.org/doc/html/rfc9204#section-5">
32+
* RFC 9204, Section 5 (SETTINGS_QPACK_MAX_TABLE_CAPACITY)</a> and registered in
33+
* the <a href="https://www.iana.org/assignments/http3-parameters/http3-parameters.xhtml#settings">
34+
* HTTP/3 SETTINGS registry (IANA)</a>.
35+
* <br>
36+
* Controls the maximum size of the dynamic table used by QPACK.
37+
*/
38+
HTTP3_SETTINGS_QPACK_MAX_TABLE_CAPACITY(0x1),
39+
40+
/**
41+
* Maximum field section size setting identifier (<b>0x6</b>).
42+
* <p>
43+
* Defined in <a href="https://datatracker.ietf.org/doc/html/rfc9114#section-7.2.4.1">
44+
* RFC 9114, Section 7.2.4.1 (SETTINGS_MAX_FIELD_SECTION_SIZE)</a> , also referenced
45+
* in the <a href="https://datatracker.ietf.org/doc/html/rfc9114#section-7.2.4.1">
46+
* HTTP/3 SETTINGS registry (RFC 9114, Section 7.2.4.1)</a> and registered in
47+
* the <a href="https://www.iana.org/assignments/http3-parameters/http3-parameters.xhtml#settings">
48+
* HTTP/3 SETTINGS registry (IANA)</a>.
49+
* <br>
50+
* Specifies the upper bound on the total size of HTTP field sections accepted by a peer.
51+
*/
52+
HTTP3_SETTINGS_MAX_FIELD_SECTION_SIZE(0x6),
53+
54+
/**
55+
* QPACK blocked streams setting identifier (<b>0x7</b>).
56+
* <p>
57+
* Defined in <a href="https://datatracker.ietf.org/doc/html/rfc9204#section-5">
58+
* RFC 9204, Section 5 (SETTINGS_QPACK_BLOCKED_STREAMS)</a> and registered in
59+
* the <a href="https://www.iana.org/assignments/http3-parameters/http3-parameters.xhtml#settings">
60+
* HTTP/3 SETTINGS registry (IANA)</a>.
61+
* <br>
62+
* Indicates the maximum number of streams that can be blocked waiting for QPACK instructions.
63+
*/
64+
HTTP3_SETTINGS_QPACK_BLOCKED_STREAMS(0x7),
65+
66+
/**
67+
* ENABLE_CONNECT_PROTOCOL setting identifier (<b>0x8</b>).
68+
* <p>
69+
* Defined and registered in <a href="https://datatracker.ietf.org/doc/html/rfc9220#section-5">
70+
* RFC 9220, Section 5 (IANA Considerations)</a> and registered in
71+
* the <a href="https://www.iana.org/assignments/http3-parameters/http3-parameters.xhtml#settings">
72+
* HTTP/3 SETTINGS registry (IANA)</a>.
73+
* <br>
74+
* Enables use of the CONNECT protocol in HTTP/3 when set to 1; disabled when 0.
75+
*/
76+
HTTP3_SETTINGS_ENABLE_CONNECT_PROTOCOL(0x8),
77+
78+
/**
79+
* ENABLE_H3_DATAGRAM setting identifier (<b>0x8</b>).
80+
* <p>
81+
* Defined and registered in <a href="https://datatracker.ietf.org/doc/html/rfc9297#name-http-3-setting">
82+
* RFC 9220, Section 5 (IANA Considerations)</a> and registered in
83+
* the <a href="https://www.iana.org/assignments/http3-parameters/http3-parameters.xhtml#settings">
84+
* HTTP/3 SETTINGS registry (IANA)</a>.
85+
* <br>
86+
* Enables use of the CONNECT protocol in HTTP/3 when set to 1; disabled when 0.
87+
*/
88+
HTTP3_SETTINGS_H3_DATAGRAM(0x33);
89+
90+
private final long id;
91+
92+
private static final Map<Long, Http3SettingIdentifier> LOOKUP = Collections.unmodifiableMap(
93+
Arrays.stream(values())
94+
.collect(Collectors.toMap(
95+
Http3SettingIdentifier::id,
96+
Function.identity()
97+
))
98+
);
99+
100+
Http3SettingIdentifier(long id) {
101+
this.id = id;
102+
}
103+
104+
/**
105+
* Returns the Identifier of {@link Http3SettingIdentifier}
106+
* for example:
107+
* SETTINGS_QPACK_MAX_TABLE_CAPACITY = 0x1 = 1 in the settings frame
108+
* <br>
109+
* @return long(represented as hexadecimal above) value of the Identifier
110+
*/
111+
public long id() {
112+
return id;
113+
}
114+
115+
/**
116+
* Returns {@link Http3SettingIdentifier}
117+
* @param id
118+
* @return {@link Http3SettingIdentifier} enum which represents @param id, null otherwise
119+
*/
120+
@Nullable
121+
public static Http3SettingIdentifier fromId(long id) {
122+
return LOOKUP.get(id);
123+
}
124+
}

0 commit comments

Comments
 (0)