http2: make res.req a normal property
The change in https://github.com/nodejs/node/pull/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: https://github.com/nodejs/node/pull/37706 Fixes: https://github.com/nodejs/node/issues/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>
This commit is contained in:
parent
ef459d86ee
commit
9f119a3581
@ -480,6 +480,7 @@ class Http2ServerResponse extends Stream {
|
|||||||
stream[kProxySocket] = null;
|
stream[kProxySocket] = null;
|
||||||
stream[kResponse] = this;
|
stream[kResponse] = this;
|
||||||
this.writable = true;
|
this.writable = true;
|
||||||
|
this.req = stream[kRequest];
|
||||||
stream.on('drain', onStreamDrain);
|
stream.on('drain', onStreamDrain);
|
||||||
stream.on('aborted', onStreamAbortedResponse);
|
stream.on('aborted', onStreamAbortedResponse);
|
||||||
stream.on('close', onStreamCloseResponse);
|
stream.on('close', onStreamCloseResponse);
|
||||||
@ -529,10 +530,6 @@ class Http2ServerResponse extends Stream {
|
|||||||
return this[kStream].headersSent;
|
return this[kStream].headersSent;
|
||||||
}
|
}
|
||||||
|
|
||||||
get req() {
|
|
||||||
return this[kStream][kRequest];
|
|
||||||
}
|
|
||||||
|
|
||||||
get sendDate() {
|
get sendDate() {
|
||||||
return this[kState].sendDate;
|
return this[kState].sendDate;
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,9 @@ server.listen(0, common.mustCall(function() {
|
|||||||
server.once('request', common.mustCall(function(request, response) {
|
server.once('request', common.mustCall(function(request, response) {
|
||||||
assert.strictEqual(response.req, request);
|
assert.strictEqual(response.req, request);
|
||||||
|
|
||||||
|
// Verify that writing to response.req is allowed.
|
||||||
|
response.req = null;
|
||||||
|
|
||||||
response.on('finish', common.mustCall(function() {
|
response.on('finish', common.mustCall(function() {
|
||||||
process.nextTick(() => {
|
process.nextTick(() => {
|
||||||
server.close();
|
server.close();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user