summaryrefslogtreecommitdiff
path: root/lib/https.js
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2011-10-04 20:51:34 +0200
committerBen Noordhuis <info@bnoordhuis.nl>2011-10-04 20:51:34 +0200
commitbc7cfd7cd7c2e513a9ac9a2820f3b6f7331735b5 (patch)
tree149564ca5e2ee3ec24462ce82788d0c6ef08761e /lib/https.js
parent976c6b0826e2a2555f63917a4de852af50945868 (diff)
downloadandroid-node-v8-bc7cfd7cd7c2e513a9ac9a2820f3b6f7331735b5.tar.gz
android-node-v8-bc7cfd7cd7c2e513a9ac9a2820f3b6f7331735b5.tar.bz2
android-node-v8-bc7cfd7cd7c2e513a9ac9a2820f3b6f7331735b5.zip
http: remove legacy http library
Diffstat (limited to 'lib/https.js')
-rw-r--r--lib/https.js48
1 files changed, 12 insertions, 36 deletions
diff --git a/lib/https.js b/lib/https.js
index 7482f3142a..c0394319b7 100644
--- a/lib/https.js
+++ b/lib/https.js
@@ -50,56 +50,32 @@ exports.createServer = function(opts, requestListener) {
// HTTPS agents.
-var agents = {};
+
+function createConnection(port, host, options) {
+ return tls.connect(port, host, options);
+};
function Agent(options) {
http.Agent.call(this, options);
-}
+ this.createConnection = createConnection;
+};
inherits(Agent, http.Agent);
-
-
Agent.prototype.defaultPort = 443;
+var globalAgent = new Agent();
-Agent.prototype._getConnection = function(options, cb) {
- if (process.features.tls_npn && !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);
+ options.createConnection = createConnection;
+ options.defaultPort = options.defaultPort || 443;
+ return http.request(options, cb);
};
-
exports.get = function(options, cb) {
options.method = 'GET';
var req = exports.request(options, cb);