Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9079bb4

Browse filesBrowse files
ronagcodebytere
authored andcommitted
http2: make compat finished match http/1
finished should true directly after end(). PR-URL: #24347 Refs: #24743 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent bbb6cc7 commit 9079bb4
Copy full SHA for 9079bb4

File tree

Expand file treeCollapse file tree

2 files changed

+7
-8
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+7
-8
lines changed
Open diff view settings
Collapse file

‎lib/internal/http2/compat.js‎

Copy file name to clipboardExpand all lines: lib/internal/http2/compat.js
+4-7Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -471,10 +471,8 @@ class Http2ServerResponse extends Stream {
471471
}
472472

473473
get finished() {
474-
const stream = this[kStream];
475-
return stream.destroyed ||
476-
stream._writableState.ended ||
477-
this[kState].closed;
474+
const state = this[kState];
475+
return state.ending;
478476
}
479477

480478
get socket() {
@@ -700,12 +698,11 @@ class Http2ServerResponse extends Stream {
700698
if (chunk !== null && chunk !== undefined)
701699
this.write(chunk, encoding);
702700

703-
const isFinished = this.finished;
704701
state.headRequest = stream.headRequest;
705702
state.ending = true;
706703

707704
if (typeof cb === 'function') {
708-
if (isFinished)
705+
if (stream.writableEnded)
709706
this.once('finish', cb);
710707
else
711708
stream.once('finish', cb);
@@ -714,7 +711,7 @@ class Http2ServerResponse extends Stream {
714711
if (!stream.headersSent)
715712
this.writeHead(this[kState].statusCode);
716713

717-
if (isFinished)
714+
if (this[kState].closed || stream.destroyed)
718715
onStreamCloseResponse.call(stream);
719716
else
720717
stream.end();
Collapse file

‎test/parallel/test-http2-compat-serverresponse-end.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http2-compat-serverresponse-end.js
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,13 @@ const {
149149
// Http2ServerResponse.end is necessary on HEAD requests in compat
150150
// for http1 compatibility
151151
const server = createServer(mustCall((request, response) => {
152-
strictEqual(response.finished, true);
153152
strictEqual(response.writableEnded, false);
153+
strictEqual(response.finished, false);
154154
response.writeHead(HTTP_STATUS_OK, { foo: 'bar' });
155+
strictEqual(response.finished, false);
155156
response.end('data', mustCall());
156157
strictEqual(response.writableEnded, true);
158+
strictEqual(response.finished, true);
157159
}));
158160
server.listen(0, mustCall(() => {
159161
const { port } = server.address();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.