test: refactor test-http-pause-resume-one-end
* 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>
This commit is contained in:
parent
3ddbea6455
commit
6f02957846
@ -1,23 +1,23 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
var http = require('http');
|
const http = require('http');
|
||||||
|
|
||||||
var server = http.Server(function(req, res) {
|
const server = http.Server(function(req, res) {
|
||||||
res.writeHead(200, {'Content-Type': 'text/plain'});
|
res.writeHead(200, {'Content-Type': 'text/plain'});
|
||||||
res.end('Hello World\n');
|
res.end('Hello World\n');
|
||||||
server.close();
|
server.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
server.listen(0, common.mustCall(function() {
|
server.listen(0, common.mustCall(function() {
|
||||||
var opts = {
|
const opts = {
|
||||||
port: this.address().port,
|
port: this.address().port,
|
||||||
headers: { connection: 'close' }
|
headers: { connection: 'close' }
|
||||||
};
|
};
|
||||||
|
|
||||||
http.get(opts, common.mustCall(function(res) {
|
http.get(opts, common.mustCall(function(res) {
|
||||||
res.on('data', common.mustCall(function(chunk) {
|
res.on('data', common.mustCall(function() {
|
||||||
res.pause();
|
res.pause();
|
||||||
setTimeout(function() {
|
setImmediate(function() {
|
||||||
res.resume();
|
res.resume();
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user