From 90403dd1d06d01ca69aea810bcaa7f41b031e8b4 Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Mon, 27 Feb 2017 01:09:30 +0800 Subject: [PATCH] http: should support userland Agent PR-URL: https://github.com/nodejs/node/pull/11567 Reviewed-By: James M Snell Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig --- lib/_http_client.js | 4 ++-- test/parallel/test-http-client-reject-unexpected-agent.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/_http_client.js b/lib/_http_client.js index d281b120c8553b..2205e89d2ae3d6 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -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; diff --git a/test/parallel/test-http-client-reject-unexpected-agent.js b/test/parallel/test-http-client-reject-unexpected-agent.js index 559166ec421ea2..e89bcfad5b5995 100644 --- a/test/parallel/test-http-client-reject-unexpected-agent.js +++ b/test/parallel/test-http-client-reject-unexpected-agent.js @@ -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` ); });