summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2017-05-09 14:32:34 -0400
committercjihrig <cjihrig@gmail.com>2017-05-11 15:28:27 -0400
commit9ce2271e813016685d1c8f9ab3e7ce6c85eee069 (patch)
tree2ba9b874dda7953030ff307f7461c3e9028539a6
parentabfd4bf9dfbf4e9817fe2c0b08476f505c4012d1 (diff)
downloadandroid-node-v8-9ce2271e813016685d1c8f9ab3e7ce6c85eee069.tar.gz
android-node-v8-9ce2271e813016685d1c8f9ab3e7ce6c85eee069.tar.bz2
android-node-v8-9ce2271e813016685d1c8f9ab3e7ce6c85eee069.zip
https: support agent construction without new
Fixes: https://github.com/nodejs/node/issues/12918 PR-URL: https://github.com/nodejs/node/pull/12927 Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
-rw-r--r--lib/https.js3
-rw-r--r--test/parallel/test-https-agent-constructor.js7
2 files changed, 10 insertions, 0 deletions
diff --git a/lib/https.js b/lib/https.js
index c44766bd6e..1ca546ac10 100644
--- a/lib/https.js
+++ b/lib/https.js
@@ -119,6 +119,9 @@ function createConnection(port, host, options) {
function Agent(options) {
+ if (!(this instanceof Agent))
+ return new Agent(options);
+
http.Agent.call(this, options);
this.defaultPort = 443;
this.protocol = 'https:';
diff --git a/test/parallel/test-https-agent-constructor.js b/test/parallel/test-https-agent-constructor.js
new file mode 100644
index 0000000000..942ad07b4a
--- /dev/null
+++ b/test/parallel/test-https-agent-constructor.js
@@ -0,0 +1,7 @@
+'use strict';
+require('../common');
+const assert = require('assert');
+const https = require('https');
+
+assert.doesNotThrow(() => { https.Agent(); });
+assert.ok(https.Agent() instanceof https.Agent);