summaryrefslogtreecommitdiff
path: root/lib/https.js
diff options
context:
space:
mode:
authorNathan Rajlich <nathan@tootallnate.net>2014-02-25 14:15:02 -0800
committerNathan Rajlich <nathan@tootallnate.net>2014-02-26 13:18:54 -0800
commitd6bbb19f1d1d6397d862d09304bc63c476f675c1 (patch)
tree7d371831c0d769125d5b4c062c69783ee697f283 /lib/https.js
parentd307bebec4a7b087e4bb3576665235e4ab086a60 (diff)
downloadandroid-node-v8-d6bbb19f1d1d6397d862d09304bc63c476f675c1.tar.gz
android-node-v8-d6bbb19f1d1d6397d862d09304bc63c476f675c1.tar.bz2
android-node-v8-d6bbb19f1d1d6397d862d09304bc63c476f675c1.zip
http, https: don't depend on `globalAgent`
For the `request()` and `get()` functions. I could never really understand why these two functions go through agent first... Especially since the user could be passing `agent: false` or a different Agent instance completely, in which `globalAgent` will be completely bypassed. Moved the relevant logic from `Agent#request()` into the `ClientRequest` constructor. Incidentally, this commit fixes #7012 (which was the original intent of this commit).
Diffstat (limited to 'lib/https.js')
-rw-r--r--lib/https.js13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/https.js b/lib/https.js
index 0041986bd5..f9011648fb 100644
--- a/lib/https.js
+++ b/lib/https.js
@@ -20,6 +20,7 @@
// USE OR OTHER DEALINGS IN THE SOFTWARE.
var tls = require('tls');
+var url = require('url');
var http = require('http');
var util = require('util');
var inherits = require('util').inherits;
@@ -126,9 +127,17 @@ exports.globalAgent = globalAgent;
exports.Agent = Agent;
exports.request = function(options, cb) {
- return globalAgent.request(options, cb);
+ if (util.isString(options)) {
+ options = url.parse(options);
+ } else {
+ options = util._extend({}, options);
+ }
+ options._defaultAgent = globalAgent;
+ return http.request(options, cb);
};
exports.get = function(options, cb) {
- return globalAgent.get(options, cb);
+ var req = exports.request(options, cb);
+ req.end();
+ return req;
};