-
Notifications
You must be signed in to change notification settings - Fork 30.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
https: made some improvements to test-https-agent.js #8517
Changes from 1 commit
7fe1e2c
b58888a
a05d57e
9748a1d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,7 @@ ipch/ | |
*.VC.opendb | ||
.vs/ | ||
.vscode/ | ||
.idea/ | ||
|
||
/config.mk | ||
/config.gypi | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,39 @@ | ||
'use strict'; | ||
var common = require('../common'); | ||
var assert = require('assert'); | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
|
||
if (!common.hasCrypto) { | ||
common.skip('missing crypto'); | ||
return; | ||
} | ||
var https = require('https'); | ||
const https = require('https'); | ||
|
||
var fs = require('fs'); | ||
const fs = require('fs'); | ||
|
||
var options = { | ||
//Gets SSL Certificate and SSL Key. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can avoid this comment. |
||
const options = { | ||
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), | ||
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') | ||
}; | ||
|
||
|
||
var server = https.Server(options, function(req, res) { | ||
//Starts up a https server using the SSL Certificate and Key. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto. |
||
const server = https.Server(options, function(req, res) { | ||
res.writeHead(200); | ||
res.end('hello world\n'); | ||
}); | ||
|
||
|
||
var responses = 0; | ||
var N = 4; | ||
var M = 4; | ||
const N = 4; | ||
const M = 4; | ||
|
||
/* | ||
the part being tested, Loops around 4 times on N, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would also remove this, the following code is clear enough. |
||
Each time it loops around another 4 times on M, | ||
each time sending a https GET request for route '/' | ||
each inner loop records the number of responses | ||
and closes the https server once the https request has been send 16 times. | ||
*/ | ||
|
||
server.listen(0, function() { | ||
for (var i = 0; i < N; i++) { | ||
|
@@ -37,7 +46,7 @@ server.listen(0, function() { | |
}, function(res) { | ||
res.resume(); | ||
console.log(res.statusCode); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about replacing this line with |
||
if (++responses == N * M) server.close(); | ||
if (++responses === N * M) server.close(); | ||
}).on('error', function(e) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would change this to |
||
console.log(e.message); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if it's better to throw the error here instead of logging the error message. |
||
process.exit(1); | ||
|
@@ -47,7 +56,11 @@ server.listen(0, function() { | |
} | ||
}); | ||
|
||
/* | ||
Asserts the number of responses match the number of loops, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same thing here, I don't think the comment is necessary. |
||
making sure all responses were sent successfully. | ||
*/ | ||
|
||
process.on('exit', function() { | ||
assert.equal(N * M, responses); | ||
assert.strictEqual(N * M, responses); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't change
.gitignore
. There is another PR specifically for this and it is still being discussed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you need
.idea/
in your .gitignore, consider adding it to a personal global.gitignore
file instead. https://help.github.com/articles/ignoring-files/#create-a-global-gitignore