don't send the request using https if the uri is http
This commit is contained in:
parent
99e625968a
commit
32620902a5
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
request = https.request(options, function (response) {
|
||||
request = http_library.request(options, function (response) {
|
||||
response.on("data", function (chunk) {
|
||||
result+= chunk
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user