http: should support userland Agent
PR-URL: https://github.com/nodejs/node/pull/11567 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
20b18236de
commit
90403dd1d0
@ -89,9 +89,9 @@ function ClientRequest(options, cb) {
|
||||
}
|
||||
// Explicitly pass through this statement as agent will not be used
|
||||
// when createConnection is provided.
|
||||
} else if (!(agent instanceof Agent.Agent)) {
|
||||
} else if (typeof agent.addRequest !== 'function') {
|
||||
throw new TypeError(
|
||||
'Agent option must be an instance of http.Agent, undefined or false.'
|
||||
'Agent option must be an Agent-like object, undefined, or false.'
|
||||
);
|
||||
}
|
||||
this.agent = agent;
|
||||
|
@ -49,7 +49,7 @@ server.listen(0, baseOptions.host, common.mustCall(function() {
|
||||
failingAgentOptions.forEach((agent) => {
|
||||
assert.throws(
|
||||
() => createRequest(agent),
|
||||
/^TypeError: Agent option must be an instance of http.Agent/,
|
||||
/^TypeError: Agent option must be an Agent-like object/,
|
||||
`Expected typeof agent: ${typeof agent} to be rejected`
|
||||
);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user