mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
9f119a3581
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>
44 lines
1.1 KiB
JavaScript
44 lines
1.1 KiB
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
const assert = require('assert');
|
|
const h2 = require('http2');
|
|
|
|
// Http2ServerResponse should expose convenience properties
|
|
|
|
const server = h2.createServer();
|
|
server.listen(0, common.mustCall(function() {
|
|
const port = server.address().port;
|
|
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();
|
|
});
|
|
}));
|
|
response.end();
|
|
}));
|
|
|
|
const url = `http://localhost:${port}`;
|
|
const client = h2.connect(url, common.mustCall(function() {
|
|
const headers = {
|
|
':path': '/foobar',
|
|
':method': 'GET',
|
|
':scheme': 'http',
|
|
':authority': `localhost:${port}`
|
|
};
|
|
const request = client.request(headers);
|
|
request.on('end', common.mustCall(function() {
|
|
client.close();
|
|
}));
|
|
request.end();
|
|
request.resume();
|
|
}));
|
|
}));
|