Browse Source

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>
v6
Rich Trott 8 years ago
parent
commit
6f02957846
  1. 10
      test/parallel/test-http-pause-resume-one-end.js

10
test/parallel/test-http-pause-resume-one-end.js

@ -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…
Cancel
Save