0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-http-client-response-timeout.js
Ben Noordhuis 7b26322f6d http: make response.setTimeout() work
Fixes: https://github.com/nodejs/node/issues/33734

PR-URL: https://github.com/nodejs/node/pull/34913
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ricky Zhou <0x19951125@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2020-10-07 13:50:22 -05:00

15 lines
400 B
JavaScript

'use strict';
const common = require('../common');
const http = require('http');
const server = http.createServer((req, res) => res.flushHeaders());
server.listen(common.mustCall(() => {
const req =
http.get({ port: server.address().port }, common.mustCall((res) => {
res.on('timeout', common.mustCall(() => req.destroy()));
res.setTimeout(1);
server.close();
}));
}));