http: make globalAgent of http and https overridable#11249
http: make globalAgent of http and https overridable#11249shubheksha wants to merge 1 commit intonodejs:masterfrom shubheksha:fix/9057
globalAgent of http and https overridable#11249Conversation
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.
/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.
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.
@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.
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.
@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.
+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