| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 94fd8f3 commit 293d223
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,33 +1,30 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | const common = require('../common'); | |
| 3 | - const assert = require('assert'); | ||
| 4 | 3 | const http = require('http'); | |
| 5 | 4 | ||
| 6 | - var options = { | ||
| 5 | + const options = { | ||
| 7 | 6 | method: 'GET', | |
| 8 | 7 | port: undefined, | |
| 9 | 8 | host: '127.0.0.1', | |
| 10 | 9 | path: '/' | |
| 11 | 10 | }; | |
| 12 | 11 | ||
| 13 | - var server = http.createServer(); | ||
| 12 | + const server = http.createServer(); | ||
| 14 | 13 | ||
| 15 | 14 | server.listen(0, options.host, function() { | |
| 16 | 15 | options.port = this.address().port; | |
| 17 | - var req = http.request(options); | ||
| 16 | + const req = http.request(options); | ||
| 18 | 17 | req.on('error', function() { | |
| 19 | 18 | // this space is intentionally left blank | |
| 20 | 19 | }); | |
| 21 | 20 | req.on('close', common.mustCall(() => server.close())); | |
| 22 | 21 | ||
| 23 | - var timeout_events = 0; | ||
| 24 | 22 | req.setTimeout(1); | |
| 25 | - req.on('timeout', common.mustCall(() => timeout_events += 1)); | ||
| 26 | - setTimeout(function() { | ||
| 27 | - req.destroy(); | ||
| 28 | - assert.strictEqual(timeout_events, 1); | ||
| 29 | - }, common.platformTimeout(100)); | ||
| 30 | - setTimeout(function() { | ||
| 31 | - req.end(); | ||
| 32 | - }, common.platformTimeout(50)); | ||
| 23 | + req.on('timeout', common.mustCall(() => { | ||
| 24 | + req.end(() => { | ||
| 25 | + setTimeout(() => { | ||
| 26 | + req.destroy(); | ||
| 27 | + }, 100); | ||
| 28 | + }); | ||
| 29 | + })); | ||
| 33 | 30 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments