From 2d3a1fd89ae199086a63a820385bbedec2b09435 Mon Sep 17 00:00:00 2001 From: hanguanqiang Date: Thu, 27 Mar 2025 09:09:00 +0800 Subject: [PATCH 1/3] http2: fix an error in an if condition in 1b693fa According to the description above, this should be checking whether frame->hd.type is NGHTTP2_GOAWAY, and the value of NGHTTP2_GOAWAY is 0x07. However, it is written as 0x03 here, which I think it is an error. --- src/node_http2.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node_http2.cc b/src/node_http2.cc index af7698797278e4..85e8787e2bfedd 100644 --- a/src/node_http2.cc +++ b/src/node_http2.cc @@ -1206,7 +1206,7 @@ int Http2Session::OnFrameNotSent(nghttp2_session* handle, // closed but the Http2Session will still be up causing a memory leak. // Therefore, if the GOAWAY frame couldn't be send due to // ERR_SESSION_CLOSING we should force close from our side. - if (frame->hd.type != 0x03) { + if (frame->hd.type != NGHTTP2_GOAWAY) { return 0; } } From cf86853125eb02f88d12000516dcff64c4d3e137 Mon Sep 17 00:00:00 2001 From: hanguanqiang Date: Tue, 1 Apr 2025 15:20:37 +0800 Subject: [PATCH 2/3] http2:correct http2 header frame content MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit previously, due to some error in the content of the header frame, the script could not exit properly, which eventually led to a timeout error,this commit correct header frame content according to http2 related protocol so that make it exited successfully. --- test/parallel/test-http2-premature-close.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-http2-premature-close.js b/test/parallel/test-http2-premature-close.js index a9b08f55d8a3b8..ace3106be05a43 100644 --- a/test/parallel/test-http2-premature-close.js +++ b/test/parallel/test-http2-premature-close.js @@ -29,9 +29,9 @@ async function requestAndClose(server) { // Send a valid HEADERS frame const headersFrame = Buffer.concat([ Buffer.from([ - 0x00, 0x00, 0x0c, // Length: 12 bytes + 0x00, 0x00, 0x0e, // Length: 12 bytes 0x01, // Type: HEADERS - 0x05, // Flags: END_HEADERS + END_STREAM + 0x04, // Flags: END_HEADERS + END_STREAM (streamId >> 24) & 0xFF, // Stream ID: high byte (streamId >> 16) & 0xFF, (streamId >> 8) & 0xFF, @@ -41,7 +41,7 @@ async function requestAndClose(server) { 0x82, // Indexed Header Field Representation (Predefined ":method: GET") 0x84, // Indexed Header Field Representation (Predefined ":path: /") 0x86, // Indexed Header Field Representation (Predefined ":scheme: http") - 0x44, 0x0a, // Custom ":authority: localhost" + 0x41, 0x09, // Custom ":authority: localhost" 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, 0x73, 0x74, ]), ]); From 2279ad5ac50fc38fa77fc205c0fe056a2ae1af63 Mon Sep 17 00:00:00 2001 From: hanguanqiang Date: Tue, 1 Apr 2025 16:46:14 +0800 Subject: [PATCH 3/3] http2: correct comments correct comments --- test/parallel/test-http2-premature-close.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-http2-premature-close.js b/test/parallel/test-http2-premature-close.js index ace3106be05a43..df30c429188b69 100644 --- a/test/parallel/test-http2-premature-close.js +++ b/test/parallel/test-http2-premature-close.js @@ -29,9 +29,9 @@ async function requestAndClose(server) { // Send a valid HEADERS frame const headersFrame = Buffer.concat([ Buffer.from([ - 0x00, 0x00, 0x0e, // Length: 12 bytes + 0x00, 0x00, 0x0e, // Length: 14 bytes 0x01, // Type: HEADERS - 0x04, // Flags: END_HEADERS + END_STREAM + 0x04, // Flags: END_HEADERS (streamId >> 24) & 0xFF, // Stream ID: high byte (streamId >> 16) & 0xFF, (streamId >> 8) & 0xFF, @@ -41,7 +41,7 @@ async function requestAndClose(server) { 0x82, // Indexed Header Field Representation (Predefined ":method: GET") 0x84, // Indexed Header Field Representation (Predefined ":path: /") 0x86, // Indexed Header Field Representation (Predefined ":scheme: http") - 0x41, 0x09, // Custom ":authority: localhost" + 0x41, 0x09, // ":authority: localhost" Length: 9 bytes 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, 0x73, 0x74, ]), ]);