Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http2: make res.req a normal property #37706

Merged
merged 1 commit into from
Mar 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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