| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent eeb2d78 commit 8a26ba1
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,24 +1,24 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | - var common = require('../common'); | ||
| 2 | + const common = require('../common'); | ||
| 3 | 3 | ||
| 4 | 4 | if (!common.hasCrypto) { | |
| 5 | 5 | common.skip('missing crypto'); | |
| 6 | 6 | return; | |
| 7 | 7 | } | |
| 8 | - var https = require('https'); | ||
| 8 | + const https = require('https'); | ||
| 9 | 9 | ||
| 10 | - var fs = require('fs'); | ||
| 10 | + const fs = require('fs'); | ||
| 11 | 11 | ||
| 12 | - var options = { | ||
| 12 | + const options = { | ||
| 13 | 13 | key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), | |
| 14 | 14 | cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') | |
| 15 | 15 | }; | |
| 16 | 16 | ||
| 17 | 17 | // a server that never replies | |
| 18 | - var server = https.createServer(options, function() { | ||
| 18 | + const server = https.createServer(options, function() { | ||
| 19 | 19 | console.log('Got request. Doing nothing.'); | |
| 20 | - }).listen(0, function() { | ||
| 21 | - var req = https.request({ | ||
| 20 | + }).listen(0, common.mustCall(function() { | ||
| 21 | + const req = https.request({ | ||
| 22 | 22 | host: 'localhost', | |
| 23 | 23 | port: this.address().port, | |
| 24 | 24 | path: '/', | |
@@ -28,26 +28,14 @@ var server = https.createServer(options, function() { | |||
| 28 | 28 | req.setTimeout(10); | |
| 29 | 29 | req.end(); | |
| 30 | 30 | ||
| 31 | - req.on('response', function(res) { | ||
| 31 | + req.on('response', function() { | ||
| 32 | 32 | console.log('got response'); | |
| 33 | 33 | }); | |
| 34 | 34 | ||
| 35 | - req.on('socket', function() { | ||
| 36 | - console.log('got a socket'); | ||
| 37 | - | ||
| 38 | - req.socket.on('connect', function() { | ||
| 39 | - console.log('socket connected'); | ||
| 40 | - }); | ||
| 41 | - | ||
| 42 | - setTimeout(function() { | ||
| 43 | - throw new Error('Did not get timeout event'); | ||
| 44 | - }, 200); | ||
| 45 | - }); | ||
| 46 | - | ||
| 47 | - req.on('timeout', function() { | ||
| 35 | + req.on('timeout', common.mustCall(function() { | ||
| 48 | 36 | console.log('timeout occurred outside'); | |
| 49 | 37 | req.destroy(); | |
| 50 | 38 | server.close(); | |
| 51 | 39 | process.exit(0); | |
| 52 | - }); | ||
| 53 | - }); | ||
| 40 | + })); | ||
| 41 | + })); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments