| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,6 +29,7 @@ const assert = require('assert'); | |||
| 29 | 29 | ||
| 30 | 30 | const http = require('http'); | |
| 31 | 31 | const net = require('net'); | |
| 32 | + const Countdown = require('../common/countdown'); | ||
| 32 | 33 | ||
| 33 | 34 | // Create a TCP server | |
| 34 | 35 | const srv = net.createServer(function(c) { | |
@@ -60,7 +61,8 @@ srv.listen(0, '127.0.0.1', common.mustCall(function() { | |||
| 60 | 61 | ['Origin', 'http://www.websocket.org'] | |
| 61 | 62 | ] | |
| 62 | 63 | ]; | |
| 63 | - let left = headers.length; | ||
| 64 | + const countdown = new Countdown(headers.length, () => srv.close()); | ||
| 65 | + | ||
| 64 | 66 | headers.forEach(function(h) { | |
| 65 | 67 | const req = http.get({ | |
| 66 | 68 | port: port, | |
@@ -87,8 +89,7 @@ srv.listen(0, '127.0.0.1', common.mustCall(function() { | |||
| 87 | 89 | assert.deepStrictEqual(expectedHeaders, res.headers); | |
| 88 | 90 | ||
| 89 | 91 | socket.end(); | |
| 90 | - if (--left === 0) | ||
| 91 | - srv.close(); | ||
| 92 | + countdown.dec(); | ||
| 92 | 93 | })); | |
| 93 | 94 | req.on('close', common.mustCall(function() { | |
| 94 | 95 | assert.strictEqual(sawUpgrade, true); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments