Fix global scope leak, and amend decision on when to use https or http libraries

This commit is contained in:
ciaranj 2012-04-24 21:11:20 +01:00
parent 1970e0045e
commit ef51782104

View File

@ -29,13 +29,16 @@ exports.OAuth2.prototype._getAccessTokenUrl= function() {
exports.OAuth2.prototype._request= function(method, url, headers, post_body, access_token, callback) {
var http_library= https;
var creds = crypto.createCredentials({ });
var parsedUrl= URL.parse( url, true );
if( parsedUrl.protocol == "https:" && !parsedUrl.port ) {
parsedUrl.port= 443;
http_library = https;
} else {
http_library = http;
}
// As this is OAUth2, we *assume* https unless told explicitly otherwise.
if( parsedUrl.protocol != "https:" ) {
http_library= http;
}
var realHeaders= {};