-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
http: make globalAgent of http and https overridable
#11249
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
Conversation
Previously `globalAgent` of `http` and `https` cannot be overriden by simply assigning a new value. This exposes those properties to allow overriding by assignment.
| if (!options.hostname) { | ||
| throw new Error('Unable to determine the domain name'); | ||
| } | ||
| } else if (options instanceof url.URL) { |
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.
/cc @jasnell Is there a faster method we could use to check for this instead of using instanceof? Like checking for a symbol or something?
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.
Actually, it would be best if we could avoid duplicating all of these options checks, since they're already being done in ClientRequest(). But it would still be nice to avoid instanceof in ClientRequest().
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.
@mscdex, I didn't want to duplicate the options check too, but w/o the tests with options of type string fail as _defaultAgent cannot be added as a property on it. Instead of this, should I just check if type of options is Object or not? Is there another workaround?
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.
typeof options === 'object' && options !== null won't work since that would return true for url.URL instances as well.
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.
@mscdex ... you could export the context symbol from internal/url and check for that. All URL instances would have that set internally.
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.
+1 to the Symbol checking solution then
|
I think this is a feature addition, so, tagging as |
|
I guess this can be closed, seems to be fixed on master |
|
@gergelyke It's not fixed for |
|
This needs a rebase |
|
Ping @shubheksha do you want to follow up on this? |
|
Closing this due to the long inactivity. @shubheksha I am sorry this could not land as is. Your work is much appreciated nevertheless! If you would like to pursue this further, please leave a comment or open a new PR. |
Previously
globalAgentofhttpandhttpscannot be overriden by simply assigning a new value. This exposes those properties to allow overriding by assignment.Fixes #9057
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
http