Skip to content

Commit

Permalink
Merge pull request #4 from akgupta/ssl_agent_bug
Browse files Browse the repository at this point in the history
fix crash in ssl connection
  • Loading branch information
mikeal committed Mar 27, 2013
2 parents 33adc70 + 702a772 commit ba0759a
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions index.js
Expand Up @@ -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);
}

2 comments on commit ba0759a

@natevw
Copy link

@natevw natevw commented on ba0759a Apr 12, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a) this could have been a lot simpler: request/request#438
b) but please push this fix to npm anyway?

@natevw
Copy link

@natevw natevw commented on ba0759a Apr 12, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For anyone else needing HTTPS support in ForeverAgent (or rather, wanting Keep-Alive support for HTTPS) here's an easy monkeypatch:

ForeverAgent.SSL.prototype.createConnection = require('tls').connect;

Please sign in to comment.