diff --git a/lib/https.js b/lib/https.js index 4ecd2e8db6..ef0c8dd046 100644 --- a/lib/https.js +++ b/lib/https.js @@ -97,6 +97,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);