diff options
author | Mikeal Rogers <mikeal.rogers@gmail.com> | 2011-07-26 00:15:15 +0200 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2011-07-26 16:59:52 +0200 |
commit | 2b929c7f1944bc9ac33fb21927f2cc96c111371b (patch) | |
tree | d1372685b25a67b981c51ad41ef5e2ae846f1c91 /lib/https.js | |
parent | 09ee29318f32fdbe68d04188795bb6c760f4835c (diff) | |
download | node-new-2b929c7f1944bc9ac33fb21927f2cc96c111371b.tar.gz |
http: http2 implementation
Diffstat (limited to 'lib/https.js')
-rw-r--r-- | lib/https.js | 42 |
1 files changed, 7 insertions, 35 deletions
diff --git a/lib/https.js b/lib/https.js index 1036ea3d78..b095ae7cad 100644 --- a/lib/https.js +++ b/lib/https.js @@ -52,56 +52,28 @@ exports.createServer = function(opts, requestListener) { // HTTPS agents. -var agents = {}; function Agent(options) { http.Agent.call(this, options); + this.createConnection = function(port, host) { + return tls.connect(port, host, options); + }; } inherits(Agent, http.Agent); - - Agent.prototype.defaultPort = 443; +var globalAgent = new Agent(); -Agent.prototype._getConnection = function(options, cb) { - if (NPN_ENABLED && !this.options.NPNProtocols) { - this.options.NPNProtocols = ['http/1.1', 'http/1.0']; - } - - var s = tls.connect(options.port, options.host, this.options, function() { - // do other checks here? - if (cb) cb(); - }); - - return s; -}; - - -function getAgent(options) { - if (!options.port) options.port = 443; - - var id = options.host + ':' + options.port; - var agent = agents[id]; - - if (!agent) { - agent = agents[id] = new Agent(options); - } - - return agent; -} -exports.getAgent = getAgent; +exports.globalAgent = globalAgent; exports.Agent = Agent; exports.request = function(options, cb) { if (options.agent === undefined) { - options.agent = getAgent(options); - } else if (options.agent === false) { - options.agent = new Agent(options); + options.agent = globalAgent; } - return http._requestFromAgent(options, cb); + return http.request(options, cb); }; - exports.get = function(options, cb) { options.method = 'GET'; var req = exports.request(options, cb); |