Skip to content
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

lib: support overriding http\s.globalAgent #25170

Commits on Dec 21, 2018

  1. lib: support overriding http\s.globalAgent

    Overriding `require('http[s]').globalAgent` is now respected by
    consequent requests.
    
    In order to achieve that, the following changes were made:
    
    1. Implmentation in `http`: `module.exports.globalAgent` is now defined
    through `Object.defineProperty`. Its getter and setter return \ set
    `require('_http_agent').globalAgent`.
    
    2. Implementation in `https`: the https `globalAgent` is not the same
    as `_http_agent`, and is defined in `https` module itself. Therefore,
    the fix here was to simply use `module.exports.globalAgent` to support
    mutation.
    
    3. According tests were added for both `http` and `https`, where in
    both we create a server, set the default agent to a newly created
    instance and make a request to that server. We then assert that the
    given instance was actually used by inspecting its sockets property.
    
    Fixes: nodejs#23281
    illBeRoy committed Dec 21, 2018
    Configuration menu
    Copy the full SHA
    633e0fe View commit details
    Browse the repository at this point in the history