Skip to content

Commit c737df6

Browse files
cjihrigdanielleadams
authored andcommitted
http2: make res.req a normal property
The change in #36505 broke userland code that already wrote to res.req. This commit updates the res.req property in the http2 compat layer to be a normal property. PR-URL: #37706 Fixes: #37705 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Mary Marchini <oss@mmarchini.me> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Michaël Zasso <targos@protonmail.com>
1 parent e384291 commit c737df6

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/internal/http2/compat.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,7 @@ class Http2ServerResponse extends Stream {
480480
stream[kProxySocket] = null;
481481
stream[kResponse] = this;
482482
this.writable = true;
483+
this.req = stream[kRequest];
483484
stream.on('drain', onStreamDrain);
484485
stream.on('aborted', onStreamAbortedResponse);
485486
stream.on('close', onStreamCloseResponse);
@@ -529,10 +530,6 @@ class Http2ServerResponse extends Stream {
529530
return this[kStream].headersSent;
530531
}
531532

532-
get req() {
533-
return this[kStream][kRequest];
534-
}
535-
536533
get sendDate() {
537534
return this[kState].sendDate;
538535
}

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

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ server.listen(0, common.mustCall(function() {
1414
server.once('request', common.mustCall(function(request, response) {
1515
assert.strictEqual(response.req, request);
1616

17+
// Verify that writing to response.req is allowed.
18+
response.req = null;
19+
1720
response.on('finish', common.mustCall(function() {
1821
process.nextTick(() => {
1922
server.close();

0 commit comments

Comments
 (0)