summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);