Skip to content

Commit

Permalink
http2: make res.req a normal property
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
Reviewed-By: Robert Nagy <[email protected]>
Reviewed-By: Mary Marchini <[email protected]>
Reviewed-By: Gerhard Stöbich <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
  • Loading branch information
cjihrig authored and danielleadams committed Mar 16, 2021
1 parent 3acba1d commit e4667eb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
5 changes: 1 addition & 4 deletions lib/internal/http2/compat.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ class Http2ServerResponse extends Stream {
stream[kProxySocket] = null;
stream[kResponse] = this;
this.writable = true;
this.req = stream[kRequest];
stream.on('drain', onStreamDrain);
stream.on('aborted', onStreamAbortedResponse);
stream.on('close', onStreamCloseResponse);
Expand Down Expand Up @@ -529,10 +530,6 @@ class Http2ServerResponse extends Stream {
return this[kStream].headersSent;
}

get req() {
return this[kStream][kRequest];
}

get sendDate() {
return this[kState].sendDate;
}
Expand Down
3 changes: 3 additions & 0 deletions test/parallel/test-http2-compat-serverresponse.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ server.listen(0, common.mustCall(function() {
server.once('request', common.mustCall(function(request, response) {
assert.strictEqual(response.req, request);

// Verify that writing to response.req is allowed.
response.req = null;

response.on('finish', common.mustCall(function() {
process.nextTick(() => {
server.close();
Expand Down

0 comments on commit e4667eb

Please sign in to comment.