From 702a772c76a85b2b91f940c3a500a14f208a097b Mon Sep 17 00:00:00 2001 From: Akhilesh Gupta Date: Wed, 27 Mar 2013 13:14:34 -0700 Subject: [PATCH] fix crash in ssl connection --- index.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 1e1d4b9..5c07928 100644 --- a/index.js +++ b/index.js @@ -97,7 +97,23 @@ ForeverAgentSSL.prototype.createConnection = createConnectionSSL ForeverAgentSSL.prototype.addRequestNoreuse = AgentSSL.prototype.addRequest function createConnectionSSL (port, host, options) { - options.port = port - options.host = host - return tls.connect(options) + if (typeof port === 'object') { + options = port; + } else if (typeof host === 'object') { + options = host; + } else if (typeof options === 'object') { + options = options; + } else { + options = {}; + } + + if (typeof port === 'number') { + options.port = port; + } + + if (typeof host === 'string') { + options.host = host; + } + + return tls.connect(options); }