From 1f3f58a2354453a61f2dc7176d0561a0e50df86a Mon Sep 17 00:00:00 2001 From: Carlos Fuentes Date: Fri, 2 May 2025 11:14:06 +0200 Subject: [PATCH 1/7] http2: add lenient flag for RFC-9113 --- lib/internal/http2/util.js | 10 ++- src/node_http2.cc | 7 ++ src/node_http2_state.h | 1 + .../test-http2-server-rfc-9113-client.js | 77 ++++++++++++++++++ .../test-http2-server-rfc-9113-server.js | 80 +++++++++++++++++++ .../test-http2-util-update-options-buffer.js | 6 +- 6 files changed, 179 insertions(+), 2 deletions(-) create mode 100644 test/parallel/test-http2-server-rfc-9113-client.js create mode 100644 test/parallel/test-http2-server-rfc-9113-server.js diff --git a/lib/internal/http2/util.js b/lib/internal/http2/util.js index 75312e5aa57c5f..ce9c43d46fe67a 100644 --- a/lib/internal/http2/util.js +++ b/lib/internal/http2/util.js @@ -229,7 +229,8 @@ const IDX_OPTIONS_MAX_SESSION_MEMORY = 8; const IDX_OPTIONS_MAX_SETTINGS = 9; const IDX_OPTIONS_STREAM_RESET_RATE = 10; const IDX_OPTIONS_STREAM_RESET_BURST = 11; -const IDX_OPTIONS_FLAGS = 12; +const IDX_OPTIONS_STRICT_HTTP_HEADER_FIELD_VALIDATION = 12; +const IDX_OPTIONS_FLAGS = 13; function updateOptionsBuffer(options) { let flags = 0; @@ -293,6 +294,13 @@ function updateOptionsBuffer(options) { optionsBuffer[IDX_OPTIONS_STREAM_RESET_BURST] = MathMax(1, options.streamResetBurst); } + + if (typeof options.strictHttpFieldValidation === 'boolean') { + flags |= (1 << IDX_OPTIONS_STRICT_HTTP_HEADER_FIELD_VALIDATION); + optionsBuffer[IDX_OPTIONS_STRICT_HTTP_HEADER_FIELD_VALIDATION] = + options.strictHttpHeaderValidation === true ? 0 : 1; + } + optionsBuffer[IDX_OPTIONS_FLAGS] = flags; } diff --git a/src/node_http2.cc b/src/node_http2.cc index 4415ea096d0ea0..d0747696e0fb8a 100644 --- a/src/node_http2.cc +++ b/src/node_http2.cc @@ -159,6 +159,13 @@ Http2Options::Http2Options(Http2State* http2_state, SessionType type) { buffer[IDX_OPTIONS_PEER_MAX_CONCURRENT_STREAMS]); } + // Validate headers in accordinace to RFC-9113 + if (flags & (1 << IDX_OPTIONS_STRICT_HTTP_HEADER_FIELD_VALIDATION)) { + nghttp2_option_set_no_rfc9113_leading_and_trailing_ws_validation( + option, + buffer[IDX_OPTIONS_STRICT_HTTP_HEADER_FIELD_VALIDATION]); + } + // The padding strategy sets the mechanism by which we determine how much // additional frame padding to apply to DATA and HEADERS frames. Currently // this is set on a per-session basis, but eventually we may switch to diff --git a/src/node_http2_state.h b/src/node_http2_state.h index 2957a2827f370e..05ba9551415dea 100644 --- a/src/node_http2_state.h +++ b/src/node_http2_state.h @@ -60,6 +60,7 @@ namespace http2 { IDX_OPTIONS_MAX_SETTINGS, IDX_OPTIONS_STREAM_RESET_RATE, IDX_OPTIONS_STREAM_RESET_BURST, + IDX_OPTIONS_STRICT_HTTP_HEADER_FIELD_VALIDATION, IDX_OPTIONS_FLAGS }; diff --git a/test/parallel/test-http2-server-rfc-9113-client.js b/test/parallel/test-http2-server-rfc-9113-client.js new file mode 100644 index 00000000000000..8ff0923b079cd4 --- /dev/null +++ b/test/parallel/test-http2-server-rfc-9113-client.js @@ -0,0 +1,77 @@ +'use strict'; + +const common = require('../common'); +if (!common.hasCrypto) + common.skip('missing crypto'); +const assert = require('assert'); +const http2 = require('http2'); +const body = + '

this is some data

'; + +const server = http2.createServer((req, res) => { + res.setHeader('foobar', 'baz '); + res.setHeader('X-POWERED-BY', 'node-test\t'); + res.setHeader('x-h2-header', '\tconnection-test'); + res.setHeader('x-h2-header-2', ' connection-test'); + res.setHeader('x-h2-header-3', 'connection-test '); + res.end(body); +}); + +const server2 = http2.createServer((req, res) => { + res.setHeader('foobar', 'baz '); + res.setHeader('X-POWERED-BY', 'node-test\t'); + res.setHeader('x-h2-header', '\tconnection-test'); + res.setHeader('x-h2-header-2', ' connection-test'); + res.setHeader('x-h2-header-3', 'connection-test '); + res.end(body); +}); + +server.listen(0, common.mustCall(() => { + server2.listen(0, common.mustCall(() => { + const client = http2.connect(`http://localhost:${server.address().port}`); + const client2 = http2.connect(`http://localhost:${server2.address().port}`, { strictHttpFieldValidation: false }); + const headers = { ':path': '/' }; + const req = client.request(headers); + + req.setEncoding('utf8'); + + req.on('response', common.mustCall(function(headers) { + assert.strictEqual(headers.foobar, undefined); + assert.strictEqual(headers['x-powered-by'], undefined); + assert.strictEqual(headers['x-powered-by'], undefined); + assert.strictEqual(headers['x-h2-header'], undefined); + assert.strictEqual(headers['x-h2-header-2'], undefined); + assert.strictEqual(headers['x-h2-header-3'], undefined); + })); + + let data = ''; + req.on('data', (d) => data += d); + + req.on('end', () => { + assert.strictEqual(body, data); + client.close(); + + const req2 = client2.request(headers); + let data2 = ''; + req2.setEncoding('utf8'); + req2.on('response', common.mustCall(function(headers) { + assert.strictEqual(headers.foobar, 'baz '); + assert.strictEqual(headers['x-powered-by'], 'node-test\t'); + assert.strictEqual(headers['x-h2-header'], '\tconnection-test'); + assert.strictEqual(headers['x-h2-header-2'], ' connection-test'); + assert.strictEqual(headers['x-h2-header-3'], 'connection-test '); + })); + req2.on('data', (d) => data2 += d); + req2.on('end', () => { + assert.strictEqual(body, data2); + client2.close(); + server.close(); + }); + req2.end(); + }); + + req.end(); + })); +})); + +server.on('error', common.mustNotCall()); diff --git a/test/parallel/test-http2-server-rfc-9113-server.js b/test/parallel/test-http2-server-rfc-9113-server.js new file mode 100644 index 00000000000000..fcf36971ea7e44 --- /dev/null +++ b/test/parallel/test-http2-server-rfc-9113-server.js @@ -0,0 +1,80 @@ +'use strict'; + +const common = require('../common'); +if (!common.hasCrypto) + common.skip('missing crypto'); +const assert = require('assert'); +const http2 = require('http2'); +const body = + '

this is some data

'; + +const server = http2.createServer((req, res) => { + assert.strictEqual(req.headers['x-powered-by'], undefined); + assert.strictEqual(req.headers.foobar, undefined); + assert.strictEqual(req.headers['x-h2-header'], undefined); + assert.strictEqual(req.headers['x-h2-header-2'], undefined); + assert.strictEqual(req.headers['x-h2-header-3'], undefined); + assert.strictEqual(req.headers['x-h2-header-4'], undefined); + res.writeHead(200); + res.end(body); +}); + +const server2 = http2.createServer({ strictHttpFieldValidation: false },(req, res) => { + assert.strictEqual(req.headers.foobar, 'baz '); + assert.strictEqual(req.headers['x-powered-by'], 'node-test\t'); + assert.strictEqual(req.headers['x-h2-header'], '\tconnection-test'); + assert.strictEqual(req.headers['x-h2-header-2'], ' connection-test'); + assert.strictEqual(req.headers['x-h2-header-3'], 'connection-test '); + assert.strictEqual(req.headers['x-h2-header-4'], 'connection-test\t'); + res.writeHead(200); + res.end(body); +}); + +server.listen(0, common.mustCall(() => { + server2.listen(0, common.mustCall(() => { + const client = http2.connect(`http://localhost:${server.address().port}`); + const client2 = http2.connect(`http://localhost:${server2.address().port}`); + const headers = { + ':path': '/', + foobar: 'baz ', + 'x-powered-by': 'node-test\t', + 'x-h2-header': '\tconnection-test', + 'x-h2-header-2': ' connection-test', + 'x-h2-header-3': 'connection-test ', + 'x-h2-header-4': 'connection-test\t' + }; + const req = client.request(headers); + + req.setEncoding('utf8'); + + req.on('response', common.mustCall(function(headers) { + assert.strictEqual(headers[':status'], 200); + })); + + let data = ''; + req.on('data', (d) => data += d); + + req.on('end', () => { + assert.strictEqual(body, data); + client.close(); + + const req2 = client2.request(headers); + let data2 = ''; + req2.setEncoding('utf8'); + req2.on('response', common.mustCall(function(headers) { + assert.strictEqual(headers[':status'], 200); + })); + req2.on('data', (d) => data2 += d); + req2.on('end', () => { + assert.strictEqual(body, data2); + client2.close(); + server.close(); + }); + req2.end(); + }); + + req.end(); + })); +})); + +server.on('error', common.mustNotCall()); diff --git a/test/parallel/test-http2-util-update-options-buffer.js b/test/parallel/test-http2-util-update-options-buffer.js index c370fe50c07439..009c2dde02761e 100644 --- a/test/parallel/test-http2-util-update-options-buffer.js +++ b/test/parallel/test-http2-util-update-options-buffer.js @@ -25,7 +25,8 @@ const IDX_OPTIONS_MAX_SESSION_MEMORY = 8; const IDX_OPTIONS_MAX_SETTINGS = 9; const IDX_OPTIONS_STREAM_RESET_RATE = 10; const IDX_OPTIONS_STREAM_RESET_BURST = 11; -const IDX_OPTIONS_FLAGS = 12; +const IDX_OPTIONS_STRICT_HTTP_HEADER_FIELD_VALIDATION = 12; +const IDX_OPTIONS_FLAGS = 13; { updateOptionsBuffer({ @@ -41,6 +42,7 @@ const IDX_OPTIONS_FLAGS = 12; maxSettings: 10, streamResetRate: 11, streamResetBurst: 12, + strictHttpHeaderFieldValidation: false }); strictEqual(optionsBuffer[IDX_OPTIONS_MAX_DEFLATE_DYNAMIC_TABLE_SIZE], 1); @@ -55,6 +57,7 @@ const IDX_OPTIONS_FLAGS = 12; strictEqual(optionsBuffer[IDX_OPTIONS_MAX_SETTINGS], 10); strictEqual(optionsBuffer[IDX_OPTIONS_STREAM_RESET_RATE], 11); strictEqual(optionsBuffer[IDX_OPTIONS_STREAM_RESET_BURST], 12); + strictEqual(optionsBuffer[IDX_OPTIONS_STRICT_HTTP_HEADER_FIELD_VALIDATION], 1); const flags = optionsBuffer[IDX_OPTIONS_FLAGS]; @@ -69,6 +72,7 @@ const IDX_OPTIONS_FLAGS = 12; ok(flags & (1 << IDX_OPTIONS_MAX_SETTINGS)); ok(flags & (1 << IDX_OPTIONS_STREAM_RESET_RATE)); ok(flags & (1 << IDX_OPTIONS_STREAM_RESET_BURST)); + ok(flags & (1 << IDX_OPTIONS_STRICT_HTTP_HEADER_FIELD_VALIDATION)); } { From 1b7f2833671a1f85ff9b04314bef22b599099ee9 Mon Sep 17 00:00:00 2001 From: Carlos Fuentes Date: Sun, 11 May 2025 11:57:45 +0200 Subject: [PATCH 2/7] fix: lint --- src/node_http2.cc | 3 +-- .../test-http2-server-rfc-9113-client.js | 10 ++++------ .../test-http2-server-rfc-9113-server.js | 18 ++++++++---------- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/node_http2.cc b/src/node_http2.cc index d0747696e0fb8a..d4f2e4675a25a1 100644 --- a/src/node_http2.cc +++ b/src/node_http2.cc @@ -162,8 +162,7 @@ Http2Options::Http2Options(Http2State* http2_state, SessionType type) { // Validate headers in accordinace to RFC-9113 if (flags & (1 << IDX_OPTIONS_STRICT_HTTP_HEADER_FIELD_VALIDATION)) { nghttp2_option_set_no_rfc9113_leading_and_trailing_ws_validation( - option, - buffer[IDX_OPTIONS_STRICT_HTTP_HEADER_FIELD_VALIDATION]); + option, buffer[IDX_OPTIONS_STRICT_HTTP_HEADER_FIELD_VALIDATION]); } // The padding strategy sets the mechanism by which we determine how much diff --git a/test/parallel/test-http2-server-rfc-9113-client.js b/test/parallel/test-http2-server-rfc-9113-client.js index 8ff0923b079cd4..ee87a6d07bc007 100644 --- a/test/parallel/test-http2-server-rfc-9113-client.js +++ b/test/parallel/test-http2-server-rfc-9113-client.js @@ -32,9 +32,8 @@ server.listen(0, common.mustCall(() => { const client2 = http2.connect(`http://localhost:${server2.address().port}`, { strictHttpFieldValidation: false }); const headers = { ':path': '/' }; const req = client.request(headers); - + req.setEncoding('utf8'); - req.on('response', common.mustCall(function(headers) { assert.strictEqual(headers.foobar, undefined); assert.strictEqual(headers['x-powered-by'], undefined); @@ -43,14 +42,13 @@ server.listen(0, common.mustCall(() => { assert.strictEqual(headers['x-h2-header-2'], undefined); assert.strictEqual(headers['x-h2-header-3'], undefined); })); - + let data = ''; req.on('data', (d) => data += d); - req.on('end', () => { assert.strictEqual(body, data); client.close(); - + const req2 = client2.request(headers); let data2 = ''; req2.setEncoding('utf8'); @@ -69,7 +67,7 @@ server.listen(0, common.mustCall(() => { }); req2.end(); }); - + req.end(); })); })); diff --git a/test/parallel/test-http2-server-rfc-9113-server.js b/test/parallel/test-http2-server-rfc-9113-server.js index fcf36971ea7e44..d5fb87e81838a7 100644 --- a/test/parallel/test-http2-server-rfc-9113-server.js +++ b/test/parallel/test-http2-server-rfc-9113-server.js @@ -19,7 +19,7 @@ const server = http2.createServer((req, res) => { res.end(body); }); -const server2 = http2.createServer({ strictHttpFieldValidation: false },(req, res) => { +const server2 = http2.createServer({ strictHttpFieldValidation: false }, (req, res) => { assert.strictEqual(req.headers.foobar, 'baz '); assert.strictEqual(req.headers['x-powered-by'], 'node-test\t'); assert.strictEqual(req.headers['x-h2-header'], '\tconnection-test'); @@ -35,29 +35,27 @@ server.listen(0, common.mustCall(() => { const client = http2.connect(`http://localhost:${server.address().port}`); const client2 = http2.connect(`http://localhost:${server2.address().port}`); const headers = { - ':path': '/', - foobar: 'baz ', + 'foobar': 'baz ', + ':path': '/', 'x-powered-by': 'node-test\t', 'x-h2-header': '\tconnection-test', 'x-h2-header-2': ' connection-test', 'x-h2-header-3': 'connection-test ', 'x-h2-header-4': 'connection-test\t' - }; + }; const req = client.request(headers); - + req.setEncoding('utf8'); - req.on('response', common.mustCall(function(headers) { assert.strictEqual(headers[':status'], 200); })); - + let data = ''; req.on('data', (d) => data += d); - req.on('end', () => { assert.strictEqual(body, data); client.close(); - + const req2 = client2.request(headers); let data2 = ''; req2.setEncoding('utf8'); @@ -72,7 +70,7 @@ server.listen(0, common.mustCall(() => { }); req2.end(); }); - + req.end(); })); })); From 6f187b0cae32993b5ecf0aa79befc8ee1fcc17b2 Mon Sep 17 00:00:00 2001 From: Carlos Fuentes Date: Sun, 11 May 2025 12:03:57 +0200 Subject: [PATCH 3/7] refactor: rename to strictFieldWhitespaceValidation --- lib/internal/http2/util.js | 10 +++++----- src/node_http2.cc | 6 +++--- src/node_http2_state.h | 2 +- test/parallel/test-http2-server-rfc-9113-client.js | 2 +- test/parallel/test-http2-server-rfc-9113-server.js | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/internal/http2/util.js b/lib/internal/http2/util.js index ce9c43d46fe67a..396623d3b9d06f 100644 --- a/lib/internal/http2/util.js +++ b/lib/internal/http2/util.js @@ -229,7 +229,7 @@ const IDX_OPTIONS_MAX_SESSION_MEMORY = 8; const IDX_OPTIONS_MAX_SETTINGS = 9; const IDX_OPTIONS_STREAM_RESET_RATE = 10; const IDX_OPTIONS_STREAM_RESET_BURST = 11; -const IDX_OPTIONS_STRICT_HTTP_HEADER_FIELD_VALIDATION = 12; +const IDX_OPTIONS_STRICT_HTTP_FIELD_WHITESPACE_VALIDATION = 12; const IDX_OPTIONS_FLAGS = 13; function updateOptionsBuffer(options) { @@ -295,10 +295,10 @@ function updateOptionsBuffer(options) { MathMax(1, options.streamResetBurst); } - if (typeof options.strictHttpFieldValidation === 'boolean') { - flags |= (1 << IDX_OPTIONS_STRICT_HTTP_HEADER_FIELD_VALIDATION); - optionsBuffer[IDX_OPTIONS_STRICT_HTTP_HEADER_FIELD_VALIDATION] = - options.strictHttpHeaderValidation === true ? 0 : 1; + if (typeof options.strictFieldWhitespaceValidation === 'boolean') { + flags |= (1 << IDX_OPTIONS_STRICT_HTTP_FIELD_WHITESPACE_VALIDATION); + optionsBuffer[IDX_OPTIONS_STRICT_HTTP_FIELD_WHITESPACE_VALIDATION] = + options.strictFieldWhitespaceValidation === true ? 0 : 1; } optionsBuffer[IDX_OPTIONS_FLAGS] = flags; diff --git a/src/node_http2.cc b/src/node_http2.cc index d4f2e4675a25a1..17da8480756fca 100644 --- a/src/node_http2.cc +++ b/src/node_http2.cc @@ -159,10 +159,10 @@ Http2Options::Http2Options(Http2State* http2_state, SessionType type) { buffer[IDX_OPTIONS_PEER_MAX_CONCURRENT_STREAMS]); } - // Validate headers in accordinace to RFC-9113 - if (flags & (1 << IDX_OPTIONS_STRICT_HTTP_HEADER_FIELD_VALIDATION)) { + // Validate headers in accordance to RFC-9113 + if (flags & (1 << IDX_OPTIONS_STRICT_HTTP_FIELD_WHITESPACE_VALIDATION)) { nghttp2_option_set_no_rfc9113_leading_and_trailing_ws_validation( - option, buffer[IDX_OPTIONS_STRICT_HTTP_HEADER_FIELD_VALIDATION]); + option, buffer[IDX_OPTIONS_STRICT_HTTP_FIELD_WHITESPACE_VALIDATION]); } // The padding strategy sets the mechanism by which we determine how much diff --git a/src/node_http2_state.h b/src/node_http2_state.h index 05ba9551415dea..914ad011e021f1 100644 --- a/src/node_http2_state.h +++ b/src/node_http2_state.h @@ -60,7 +60,7 @@ namespace http2 { IDX_OPTIONS_MAX_SETTINGS, IDX_OPTIONS_STREAM_RESET_RATE, IDX_OPTIONS_STREAM_RESET_BURST, - IDX_OPTIONS_STRICT_HTTP_HEADER_FIELD_VALIDATION, + IDX_OPTIONS_STRICT_HTTP_FIELD_WHITESPACE_VALIDATION, IDX_OPTIONS_FLAGS }; diff --git a/test/parallel/test-http2-server-rfc-9113-client.js b/test/parallel/test-http2-server-rfc-9113-client.js index ee87a6d07bc007..afd967724e6a2b 100644 --- a/test/parallel/test-http2-server-rfc-9113-client.js +++ b/test/parallel/test-http2-server-rfc-9113-client.js @@ -29,7 +29,7 @@ const server2 = http2.createServer((req, res) => { server.listen(0, common.mustCall(() => { server2.listen(0, common.mustCall(() => { const client = http2.connect(`http://localhost:${server.address().port}`); - const client2 = http2.connect(`http://localhost:${server2.address().port}`, { strictHttpFieldValidation: false }); + const client2 = http2.connect(`http://localhost:${server2.address().port}`, { strictFieldWhitespaceValidation: false }); const headers = { ':path': '/' }; const req = client.request(headers); diff --git a/test/parallel/test-http2-server-rfc-9113-server.js b/test/parallel/test-http2-server-rfc-9113-server.js index d5fb87e81838a7..14a4766a374710 100644 --- a/test/parallel/test-http2-server-rfc-9113-server.js +++ b/test/parallel/test-http2-server-rfc-9113-server.js @@ -19,7 +19,7 @@ const server = http2.createServer((req, res) => { res.end(body); }); -const server2 = http2.createServer({ strictHttpFieldValidation: false }, (req, res) => { +const server2 = http2.createServer({ strictFieldWhitespaceValidation: false }, (req, res) => { assert.strictEqual(req.headers.foobar, 'baz '); assert.strictEqual(req.headers['x-powered-by'], 'node-test\t'); assert.strictEqual(req.headers['x-h2-header'], '\tconnection-test'); From 96415de092f67dac005323a99cf556a0a1ca79a9 Mon Sep 17 00:00:00 2001 From: Carlos Fuentes Date: Sun, 11 May 2025 12:11:51 +0200 Subject: [PATCH 4/7] docs: add documentation --- doc/api/http2.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/doc/api/http2.md b/doc/api/http2.md index dc741338781bce..ae900aa31b47d5 100644 --- a/doc/api/http2.md +++ b/doc/api/http2.md @@ -2899,6 +2899,10 @@ changes: a server should wait when an [`'unknownProtocol'`][] is emitted. If the socket has not been destroyed by that time the server will destroy it. **Default:** `10000`. + * `strictFieldWhitespaceValidation` {boolean} If `true`, it turns on strict leading + and trailing whitespace validation for HTTP/2 header field names and values + as per [RFC-9113](https://www.rfc-editor.org/rfc/rfc9113.html#section-8.2.1). + **Default:** `true`. * ...: Any [`net.createServer()`][] option can be provided. * `onRequestHandler` {Function} See [Compatibility API][] * Returns: {Http2Server} @@ -3070,6 +3074,10 @@ changes: a server should wait when an [`'unknownProtocol'`][] event is emitted. If the socket has not been destroyed by that time the server will destroy it. **Default:** `10000`. + * `strictFieldWhitespaceValidation` {boolean} If `true`, it turns on strict leading + and trailing whitespace validation for HTTP/2 header field names and values + as per [RFC-9113](https://www.rfc-editor.org/rfc/rfc9113.html#section-8.2.1). + **Default:** `true`. * `onRequestHandler` {Function} See [Compatibility API][] * Returns: {Http2SecureServer} @@ -3225,6 +3233,10 @@ changes: a server should wait when an [`'unknownProtocol'`][] event is emitted. If the socket has not been destroyed by that time the server will destroy it. **Default:** `10000`. + * `strictFieldWhitespaceValidation` {boolean} If `true`, it turns on strict leading + and trailing whitespace validation for HTTP/2 header field names and values + as per [RFC-9113](https://www.rfc-editor.org/rfc/rfc9113.html#section-8.2.1). + **Default:** `true`. * `listener` {Function} Will be registered as a one-time listener of the [`'connect'`][] event. * Returns: {ClientHttp2Session} From 3e9a3f2ea9ebedc08a0e7dfaa8bea882058316b3 Mon Sep 17 00:00:00 2001 From: Carlos Fuentes Date: Thu, 15 May 2025 19:07:45 +0200 Subject: [PATCH 5/7] test: fix lenient flag tests --- test/parallel/test-http2-util-update-options-buffer.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-http2-util-update-options-buffer.js b/test/parallel/test-http2-util-update-options-buffer.js index 009c2dde02761e..26e220e6b7b507 100644 --- a/test/parallel/test-http2-util-update-options-buffer.js +++ b/test/parallel/test-http2-util-update-options-buffer.js @@ -25,7 +25,7 @@ const IDX_OPTIONS_MAX_SESSION_MEMORY = 8; const IDX_OPTIONS_MAX_SETTINGS = 9; const IDX_OPTIONS_STREAM_RESET_RATE = 10; const IDX_OPTIONS_STREAM_RESET_BURST = 11; -const IDX_OPTIONS_STRICT_HTTP_HEADER_FIELD_VALIDATION = 12; +const IDX_OPTIONS_STRICT_HTTP_FIELD_WHITESPACE_VALIDATION = 12; const IDX_OPTIONS_FLAGS = 13; { @@ -42,7 +42,7 @@ const IDX_OPTIONS_FLAGS = 13; maxSettings: 10, streamResetRate: 11, streamResetBurst: 12, - strictHttpHeaderFieldValidation: false + strictFieldWhitespaceValidation: false }); strictEqual(optionsBuffer[IDX_OPTIONS_MAX_DEFLATE_DYNAMIC_TABLE_SIZE], 1); @@ -57,7 +57,7 @@ const IDX_OPTIONS_FLAGS = 13; strictEqual(optionsBuffer[IDX_OPTIONS_MAX_SETTINGS], 10); strictEqual(optionsBuffer[IDX_OPTIONS_STREAM_RESET_RATE], 11); strictEqual(optionsBuffer[IDX_OPTIONS_STREAM_RESET_BURST], 12); - strictEqual(optionsBuffer[IDX_OPTIONS_STRICT_HTTP_HEADER_FIELD_VALIDATION], 1); + strictEqual(optionsBuffer[IDX_OPTIONS_STRICT_HTTP_FIELD_WHITESPACE_VALIDATION], 1); const flags = optionsBuffer[IDX_OPTIONS_FLAGS]; @@ -72,7 +72,7 @@ const IDX_OPTIONS_FLAGS = 13; ok(flags & (1 << IDX_OPTIONS_MAX_SETTINGS)); ok(flags & (1 << IDX_OPTIONS_STREAM_RESET_RATE)); ok(flags & (1 << IDX_OPTIONS_STREAM_RESET_BURST)); - ok(flags & (1 << IDX_OPTIONS_STRICT_HTTP_HEADER_FIELD_VALIDATION)); + ok(flags & (1 << IDX_OPTIONS_STRICT_HTTP_FIELD_WHITESPACE_VALIDATION)); } { From 66cfc88a6c79fa81c0aee6270894cc55eb0744c9 Mon Sep 17 00:00:00 2001 From: Carlos Fuentes Date: Thu, 15 May 2025 20:52:50 +0200 Subject: [PATCH 6/7] fix: tangling servers --- test/parallel/test-http2-server-rfc-9113-client.js | 7 ++++++- test/parallel/test-http2-server-rfc-9113-server.js | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-http2-server-rfc-9113-client.js b/test/parallel/test-http2-server-rfc-9113-client.js index afd967724e6a2b..21978f4a9a19b4 100644 --- a/test/parallel/test-http2-server-rfc-9113-client.js +++ b/test/parallel/test-http2-server-rfc-9113-client.js @@ -48,6 +48,9 @@ server.listen(0, common.mustCall(() => { req.on('end', () => { assert.strictEqual(body, data); client.close(); + client.on('close', common.mustCall(() => { + server.close(); + })) const req2 = client2.request(headers); let data2 = ''; @@ -63,7 +66,9 @@ server.listen(0, common.mustCall(() => { req2.on('end', () => { assert.strictEqual(body, data2); client2.close(); - server.close(); + client2.on('close', common.mustCall(() => { + server2.close(); + })); }); req2.end(); }); diff --git a/test/parallel/test-http2-server-rfc-9113-server.js b/test/parallel/test-http2-server-rfc-9113-server.js index 14a4766a374710..b05bdb2f8cbc37 100644 --- a/test/parallel/test-http2-server-rfc-9113-server.js +++ b/test/parallel/test-http2-server-rfc-9113-server.js @@ -55,6 +55,9 @@ server.listen(0, common.mustCall(() => { req.on('end', () => { assert.strictEqual(body, data); client.close(); + client.on('close', common.mustCall(() => { + server.close(); + })); const req2 = client2.request(headers); let data2 = ''; @@ -66,7 +69,9 @@ server.listen(0, common.mustCall(() => { req2.on('end', () => { assert.strictEqual(body, data2); client2.close(); - server.close(); + client2.on('close', common.mustCall(() => { + server2.close(); + })); }); req2.end(); }); From 2c4db31e3566ee0431c21e4a25fa0cccfba3562d Mon Sep 17 00:00:00 2001 From: Carlos Fuentes Date: Thu, 15 May 2025 20:57:06 +0200 Subject: [PATCH 7/7] fix: lint --- test/parallel/test-http2-server-rfc-9113-client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-http2-server-rfc-9113-client.js b/test/parallel/test-http2-server-rfc-9113-client.js index 21978f4a9a19b4..caeb7e1fd74361 100644 --- a/test/parallel/test-http2-server-rfc-9113-client.js +++ b/test/parallel/test-http2-server-rfc-9113-client.js @@ -50,7 +50,7 @@ server.listen(0, common.mustCall(() => { client.close(); client.on('close', common.mustCall(() => { server.close(); - })) + })); const req2 = client2.request(headers); let data2 = '';