summaryrefslogtreecommitdiff
path: root/test/parallel/test-http-client-override-global-agent.js
AgeCommit message (Collapse)Author
2019-03-27benchmark,doc,lib: capitalize more commentsRuben Bridgewater
PR-URL: https://github.com/nodejs/node/pull/26849 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
2019-01-08lib: support overriding http\s.globalAgentRoy Sommer
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: https://github.com/nodejs/node/issues/23281 PR-URL: https://github.com/nodejs/node/pull/25170 Reviewed-By: James M Snell <jasnell@gmail.com>