Skip to content

Commit

Permalink
http: should support userland Agent
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Feb 27, 2017
1 parent 813b312 commit f17d533
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/_http_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,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.'
);
}
self.agent = agent;
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-http-client-reject-unexpected-agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`
);
});
Expand Down

0 comments on commit f17d533

Please sign in to comment.