mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 18:25:13 +08:00
http2: return this for Http2ServerRequest#setTimeout
Fixes: https://github.com/nodejs/node/issues/33993 PR-URL: https://github.com/nodejs/node/pull/33994 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Zeyu Yang <himself65@outlook.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
This commit is contained in:
1 parent
3646872f60
commit
ac80fed3b8
2 files changed
+6
-4
No files matched your search
@@ -411,9 +411,9 @@ class Http2ServerRequest extends Readable {
|
||||
}
|
||||
|
||||
setTimeout(msecs, callback) {
|
||||
if (this[kState].closed)
|
||||
return;
|
||||
this[kStream].setTimeout(msecs, callback);
|
||||
if (!this[kState].closed)
|
||||
this[kStream].setTimeout(msecs, callback);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,15 +3,17 @@
|
||||
const common = require('../common');
|
||||
if (!common.hasCrypto)
|
||||
common.skip('missing crypto');
|
||||
const assert = require('assert');
|
||||
const http2 = require('http2');
|
||||
|
||||
const msecs = common.platformTimeout(1);
|
||||
const server = http2.createServer();
|
||||
|
||||
server.on('request', (req, res) => {
|
||||
req.setTimeout(msecs, common.mustCall(() => {
|
||||
const request = req.setTimeout(msecs, common.mustCall(() => {
|
||||
res.end();
|
||||
}));
|
||||
assert.strictEqual(request, req);
|
||||
req.on('timeout', common.mustCall());
|
||||
res.on('finish', common.mustCall(() => {
|
||||
req.setTimeout(msecs, common.mustNotCall());
|
||||
|
||||
Reference in new issue
Block a user