| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,6 +3,7 @@ | |||
| 3 | 3 | const common = require('../common'); | |
| 4 | 4 | const assert = require('assert'); | |
| 5 | 5 | const http = require('http'); | |
| 6 | + const Countdown = require('../common/countdown'); | ||
| 6 | 7 | ||
| 7 | 8 | function explicit(req, res) { | |
| 8 | 9 | assert.throws(() => { | |
@@ -34,13 +35,12 @@ const server = http.createServer((req, res) => { | |||
| 34 | 35 | } | |
| 35 | 36 | }).listen(0, common.mustCall(() => { | |
| 36 | 37 | const hostname = 'localhost'; | |
| 38 | + const countdown = new Countdown(2, () => server.close()); | ||
| 37 | 39 | const url = `http://${hostname}:${server.address().port}`; | |
| 38 | - let left = 2; | ||
| 39 | 40 | const check = common.mustCall((res) => { | |
| 40 | - left--; | ||
| 41 | 41 | assert.notStrictEqual(res.headers['content-type'], 'text/html'); | |
| 42 | 42 | assert.notStrictEqual(res.headers['content-type'], 'gotcha'); | |
| 43 | - if (left === 0) server.close(); | ||
| 43 | + countdown.dec(); | ||
| 44 | 44 | }, 2); | |
| 45 | 45 | http.get(`${url}/explicit`, check).end(); | |
| 46 | 46 | http.get(`${url}/implicit`, check).end(); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments