| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,9 +23,9 @@ | |||
| 23 | 23 | require('../common'); | |
| 24 | 24 | const assert = require('assert'); | |
| 25 | 25 | const http = require('http'); | |
| 26 | + const Countdown = require('../common/countdown'); | ||
| 26 | 27 | ||
| 27 | - let nresponses = 0; | ||
| 28 | - | ||
| 28 | + const countdown = new Countdown(2, () => server.close()); | ||
| 29 | 29 | const server = http.createServer(function(req, res) { | |
| 30 | 30 | if (req.url === '/one') { | |
| 31 | 31 | res.writeHead(200, [['set-cookie', 'A'], | |
@@ -55,9 +55,7 @@ server.on('listening', function() { | |||
| 55 | 55 | }); | |
| 56 | 56 | ||
| 57 | 57 | res.on('end', function() { | |
| 58 | - if (++nresponses === 2) { | ||
| 59 | - server.close(); | ||
| 60 | - } | ||
| 58 | + countdown.dec(); | ||
| 61 | 59 | }); | |
| 62 | 60 | }); | |
| 63 | 61 | ||
@@ -72,14 +70,8 @@ server.on('listening', function() { | |||
| 72 | 70 | }); | |
| 73 | 71 | ||
| 74 | 72 | res.on('end', function() { | |
| 75 | - if (++nresponses === 2) { | ||
| 76 | - server.close(); | ||
| 77 | - } | ||
| 73 | + countdown.dec(); | ||
| 78 | 74 | }); | |
| 79 | 75 | }); | |
| 80 | 76 | ||
| 81 | 77 | }); | |
| 82 | - | ||
| 83 | - process.on('exit', function() { | ||
| 84 | - assert.strictEqual(2, nresponses); | ||
| 85 | - }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments