-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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: allow url and options to be passed to https.request #22003
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const https = require('https'); | ||
const fixtures = require('../common/fixtures'); | ||
|
||
if (!common.hasCrypto) | ||
common.skip('missing crypto'); | ||
|
||
const options = { | ||
key: fixtures.readKey('agent1-key.pem'), | ||
cert: fixtures.readKey('agent1-cert.pem'), | ||
ca: fixtures.readKey('ca1-cert.pem') | ||
}; | ||
|
||
// Test providing both a url and options, with the options partially | ||
// replacing address and port portions of the URL provided. | ||
{ | ||
const server = https.createServer( | ||
options, | ||
common.mustCall((req, res) => { | ||
assert.strictEqual(req.url, '/testpath'); | ||
res.end(); | ||
server.close(); | ||
}) | ||
); | ||
|
||
server.listen( | ||
0, | ||
common.mustCall(() => { | ||
https.get( | ||
'https://example.com/testpath', | ||
|
||
{ | ||
hostname: 'localhost', | ||
port: server.address().port, | ||
rejectUnauthorized: false | ||
}, | ||
|
||
common.mustCall((res) => { | ||
res.resume(); | ||
}) | ||
); | ||
}) | ||
); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Last I checked, this was still significantly slower in V8 I think?
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.
Fixed in Node 8.3? See https://github.com/davidmarkclements/v8-perf
Responding to your original suggestions:
The issue is that without additional methods, it never would be called... unless we duplicated the entire constructor.
This will impact the ability to add future arguments. And we are currently dealing with three arguments, all optional...
I went this way for now.
The other option:
This is clean and would work. The symbols would need to be exported by
lib/_http_client.js
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.
I would prefer it. Unfortunately there is a lot of monkey patching around core methods, and I would prefer this would be as private as possible. I would not block this for it.
If you feel strongly about going
_
, then ok.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.
@mcollina I'm not following.... in particular, I'm not sure what 'it' refers to.
Should I go back to the previous approach of subclassing ClientRequest for https, and introducing two new methods, this time with the method names being Symbols? My thoughts are that that approach is more understandable and maintainable.
Or would you prefer the current approach which duplicates a bit of code, but doesn't introduce any new methods. My thoughts are that approach is more private.
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.
I was actually commenting on some old code. The current approach is fine. LGTM
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.
@rubys I'm not sure what you mean,
HttpsClientRequest
would extend fromClientRequest
and be empty itself (no explicit constructor or additional methods). Then insideClientRequest
, checkingthis.constructor
like: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.
@McDex Fair point, but making that work would involve a circular require.
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.
@rubys Not if it's lazy loaded.