| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 167b394 commit 23a5eeb
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,51 +1,51 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | - require('../common'); | ||
| 3 | - var assert = require('assert'); | ||
| 4 | - var http = require('http'); | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const assert = require('assert'); | ||
| 4 | + const http = require('http'); | ||
| 5 | 5 | ||
| 6 | - var body = 'hello world\n'; | ||
| 6 | + const server = http.createServer(common.mustCall((req, res) => { | ||
| 7 | + const body = 'hello world\n'; | ||
| 7 | 8 | ||
| 8 | - var server = http.createServer(function(req, res) { | ||
| 9 | 9 | res.writeHead(200, {'Content-Length': body.length}); | |
| 10 | 10 | res.write(body); | |
| 11 | 11 | res.end(); | |
| 12 | - }); | ||
| 12 | + }, 3)); | ||
| 13 | 13 | ||
| 14 | - var agent = new http.Agent({maxSockets: 1}); | ||
| 15 | - var headers = {'connection': 'keep-alive'}; | ||
| 16 | - var name; | ||
| 14 | + const agent = new http.Agent({maxSockets: 1}); | ||
| 15 | + const headers = {'connection': 'keep-alive'}; | ||
| 16 | + let name; | ||
| 17 | 17 | ||
| 18 | - server.listen(0, function() { | ||
| 18 | + server.listen(0, common.mustCall(function() { | ||
| 19 | 19 | name = agent.getName({ port: this.address().port }); | |
| 20 | 20 | http.get({ | |
| 21 | 21 | path: '/', headers: headers, port: this.address().port, agent: agent | |
| 22 | - }, function(response) { | ||
| 23 | - assert.equal(agent.sockets[name].length, 1); | ||
| 24 | - assert.equal(agent.requests[name].length, 2); | ||
| 22 | + }, common.mustCall((response) => { | ||
| 23 | + assert.strictEqual(agent.sockets[name].length, 1); | ||
| 24 | + assert.strictEqual(agent.requests[name].length, 2); | ||
| 25 | 25 | response.resume(); | |
| 26 | - }); | ||
| 26 | + })); | ||
| 27 | 27 | ||
| 28 | 28 | http.get({ | |
| 29 | 29 | path: '/', headers: headers, port: this.address().port, agent: agent | |
| 30 | - }, function(response) { | ||
| 31 | - assert.equal(agent.sockets[name].length, 1); | ||
| 32 | - assert.equal(agent.requests[name].length, 1); | ||
| 30 | + }, common.mustCall((response) => { | ||
| 31 | + assert.strictEqual(agent.sockets[name].length, 1); | ||
| 32 | + assert.strictEqual(agent.requests[name].length, 1); | ||
| 33 | 33 | response.resume(); | |
| 34 | - }); | ||
| 34 | + })); | ||
| 35 | 35 | ||
| 36 | 36 | http.get({ | |
| 37 | 37 | path: '/', headers: headers, port: this.address().port, agent: agent | |
| 38 | - }, function(response) { | ||
| 39 | - response.on('end', function() { | ||
| 40 | - assert.equal(agent.sockets[name].length, 1); | ||
| 38 | + }, common.mustCall((response) => { | ||
| 39 | + response.on('end', common.mustCall(() => { | ||
| 40 | + assert.strictEqual(agent.sockets[name].length, 1); | ||
| 41 | 41 | assert(!agent.requests.hasOwnProperty(name)); | |
| 42 | 42 | server.close(); | |
| 43 | - }); | ||
| 43 | + })); | ||
| 44 | 44 | response.resume(); | |
| 45 | - }); | ||
| 46 | - }); | ||
| 45 | + })); | ||
| 46 | + })); | ||
| 47 | 47 | ||
| 48 | - process.on('exit', function() { | ||
| 48 | + process.on('exit', () => { | ||
| 49 | 49 | assert(!agent.sockets.hasOwnProperty(name)); | |
| 50 | 50 | assert(!agent.requests.hasOwnProperty(name)); | |
| 51 | 51 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments