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 {