Commit 6678d6f71d9 for nodejs
commit 6678d6f71d94804aa90dfa9e68b14ec48fe59d43
Author: Efe Karasakal <hi@efe.dev>
Date: Mon Oct 19 14:35:33 2026 +0200
quic: reuse header support assertion
Signed-off-by: Efe Karasakal <hi@efe.dev>
PR-URL: https://github.com/nodejs/node/pull/66777
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
Reviewed-By: Tim Perry <pimterry@gmail.com>
diff --git a/lib/internal/quic/quic.js b/lib/internal/quic/quic.js
index 177965510e0..d80b5846682 100644
--- a/lib/internal/quic/quic.js
+++ b/lib/internal/quic/quic.js
@@ -2165,10 +2165,7 @@ class QuicStream {
sendHeaders(headers, options = kEmptyObject) {
assertIsQuicStream(this);
if (this.destroyed) return false;
- if (getQuicSessionState(this.#inner.session).headersSupported === 2) {
- throw new ERR_INVALID_STATE(
- 'The negotiated QUIC application protocol does not support headers');
- }
+ assertHeadersSupported(this.#inner.session);
validateObject(headers, 'headers');
const { terminal = false } = options;
const headerString = buildNgHeaderString(
@@ -2187,10 +2184,7 @@ class QuicStream {
sendInformationalHeaders(headers) {
assertIsQuicStream(this);
if (this.destroyed) return false;
- if (getQuicSessionState(this.#inner.session).headersSupported === 2) {
- throw new ERR_INVALID_STATE(
- 'The negotiated QUIC application protocol does not support headers');
- }
+ assertHeadersSupported(this.#inner.session);
validateObject(headers, 'headers');
const headerString = buildNgHeaderString(
headers, assertValidPseudoHeader, true);
@@ -2208,10 +2202,7 @@ class QuicStream {
sendTrailers(headers) {
assertIsQuicStream(this);
if (this.destroyed) return false;
- if (getQuicSessionState(this.#inner.session).headersSupported === 2) {
- throw new ERR_INVALID_STATE(
- 'The negotiated QUIC application protocol does not support headers');
- }
+ assertHeadersSupported(this.#inner.session);
validateObject(headers, 'headers');
const headerString = buildNgHeaderString(headers);
return sendHeaders(
@@ -2683,10 +2674,7 @@ class QuicStream {
[kSendHeaders](headers, kind = kHeadersKindInitial,
flags = kHeadersFlagsTerminal) {
validateObject(headers, 'headers');
- if (getQuicSessionState(this.#inner.session).headersSupported === 2) {
- throw new ERR_INVALID_STATE(
- 'The negotiated QUIC application protocol does not support headers');
- }
+ assertHeadersSupported(this.#inner.session);
if (this.pending) {
debug('pending stream enqueuing headers', headers);
} else {