From e0a7eb3c1e1b7d4bbfcae62462aaf573dbd1eec8 Mon Sep 17 00:00:00 2001 From: Efe Karasakal Date: Wed, 14 Oct 2026 21:55:45 +0200 Subject: [PATCH] quic: reuse header support assertion Signed-off-by: Efe Karasakal --- lib/internal/quic/quic.js | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/lib/internal/quic/quic.js b/lib/internal/quic/quic.js index d163311dc182..24b120742002 100644 --- a/lib/internal/quic/quic.js +++ b/lib/internal/quic/quic.js @@ -2160,10 +2160,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( @@ -2182,10 +2179,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); @@ -2203,10 +2197,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( @@ -2678,10 +2669,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 {