Merge remote-tracking branch 'dmathieu/fix_http' into not_require_http
Conflicts: lib/oauth2.js
This commit is contained in:
commit
1970e0045e
@ -1,6 +1,7 @@
|
||||
var querystring= require('querystring'),
|
||||
crypto= require('crypto'),
|
||||
https= require('https'),
|
||||
http= require('http'),
|
||||
URL= require('url'),
|
||||
OAuthUtils= require('./_utils');
|
||||
|
||||
@ -30,7 +31,12 @@ exports.OAuth2.prototype._request= function(method, url, headers, post_body, acc
|
||||
|
||||
var creds = crypto.createCredentials({ });
|
||||
var parsedUrl= URL.parse( url, true );
|
||||
if( parsedUrl.protocol == "https:" && !parsedUrl.port ) parsedUrl.port= 443;
|
||||
if( parsedUrl.protocol == "https:" && !parsedUrl.port ) {
|
||||
parsedUrl.port= 443;
|
||||
http_library = https;
|
||||
} else {
|
||||
http_library = http;
|
||||
}
|
||||
|
||||
var realHeaders= {};
|
||||
if( headers ) {
|
||||
@ -72,7 +78,7 @@ exports.OAuth2.prototype._request= function(method, url, headers, post_body, acc
|
||||
}
|
||||
}
|
||||
|
||||
var request = https.request(options, function (response) {
|
||||
var request = http_library.request(options, function (response) {
|
||||
response.on("data", function (chunk) {
|
||||
result+= chunk
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user