mirror of
https://github.com/nodejs/node.git
synced 2025-04-30 15:41:06 +00:00

* setTimeout() with no duration -> setImmediate() * var -> const * remove unused variable `chunk` PR-URL: https://github.com/nodejs/node/pull/10210 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
28 lines
625 B
JavaScript
28 lines
625 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const http = require('http');
|
|
|
|
const server = http.Server(function(req, res) {
|
|
res.writeHead(200, {'Content-Type': 'text/plain'});
|
|
res.end('Hello World\n');
|
|
server.close();
|
|
});
|
|
|
|
server.listen(0, common.mustCall(function() {
|
|
const opts = {
|
|
port: this.address().port,
|
|
headers: { connection: 'close' }
|
|
};
|
|
|
|
http.get(opts, common.mustCall(function(res) {
|
|
res.on('data', common.mustCall(function() {
|
|
res.pause();
|
|
setImmediate(function() {
|
|
res.resume();
|
|
});
|
|
}));
|
|
|
|
res.on('end', common.mustCall(function() {}));
|
|
}));
|
|
}));
|