Skip to content

Commit 90403dd

Browse files
fengmk2jasnell
authored andcommitted
http: should support userland Agent
PR-URL: #11567 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 20b1823 commit 90403dd

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/_http_client.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ function ClientRequest(options, cb) {
8989
}
9090
// Explicitly pass through this statement as agent will not be used
9191
// when createConnection is provided.
92-
} else if (!(agent instanceof Agent.Agent)) {
92+
} else if (typeof agent.addRequest !== 'function') {
9393
throw new TypeError(
94-
'Agent option must be an instance of http.Agent, undefined or false.'
94+
'Agent option must be an Agent-like object, undefined, or false.'
9595
);
9696
}
9797
this.agent = agent;

test/parallel/test-http-client-reject-unexpected-agent.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ server.listen(0, baseOptions.host, common.mustCall(function() {
4949
failingAgentOptions.forEach((agent) => {
5050
assert.throws(
5151
() => createRequest(agent),
52-
/^TypeError: Agent option must be an instance of http.Agent/,
52+
/^TypeError: Agent option must be an Agent-like object/,
5353
`Expected typeof agent: ${typeof agent} to be rejected`
5454
);
5555
});

0 commit comments

Comments
 (0)