Merge branch 'not_require_http' into merge_mayhem
This commit is contained in:
commit
5d0072d759
@ -10,7 +10,7 @@ Also provides rudimentary OAuth2 support, tested against facebook connect and gi
|
|||||||
Change History
|
Change History
|
||||||
==============
|
==============
|
||||||
|
|
||||||
* 0.10.0 - OAuth2: Pass back any extra response data for calls to getOAuthAccessToken (Thanks to Tang Bo Hao)
|
* 0.10.0 - OAuth2: Pass back any extra response data for calls to getOAuthAccessToken (Thanks to Tang Bo Hao) OAuth2: Don't force a https request if given a http url (Thanks to Damien Mathieu)
|
||||||
* 0.9.6 - Support for 302 redirects on OAuth2 (Thanks Patrick Negri). Some code tidying. ( Thanks to Raoul Millais )
|
* 0.9.6 - Support for 302 redirects on OAuth2 (Thanks Patrick Negri). Some code tidying. ( Thanks to Raoul Millais )
|
||||||
* 0.9.5 - Allow usage of HTTP verbs other than GET for retrieving the access and request tokens (OAuth1) (Thanks to Raoul Millais)
|
* 0.9.5 - Allow usage of HTTP verbs other than GET for retrieving the access and request tokens (OAuth1) (Thanks to Raoul Millais)
|
||||||
* 0.9.4 - Support for OAuth providers that drop connections (don't send response lengths? [Google]) And change OAuth2 getOAuthAccessToken to POST rather than GET ( Possible Breaking change!!! ... re-tested against Google, Github, Facebook, FourSquare and Janrain and seems ok .. is closer to the spec (v20) )
|
* 0.9.4 - Support for OAuth providers that drop connections (don't send response lengths? [Google]) And change OAuth2 getOAuthAccessToken to POST rather than GET ( Possible Breaking change!!! ... re-tested against Google, Github, Facebook, FourSquare and Janrain and seems ok .. is closer to the spec (v20) )
|
||||||
@ -41,3 +41,4 @@ Contributors
|
|||||||
* Raoul Millais
|
* Raoul Millais
|
||||||
* Patrick Negri - http://github.com/pnegri
|
* Patrick Negri - http://github.com/pnegri
|
||||||
* Tang Bo Hao - http://github.com/btspoony
|
* Tang Bo Hao - http://github.com/btspoony
|
||||||
|
* Damien Mathieu - http://42.dmathieu.com
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
var querystring= require('querystring'),
|
var querystring= require('querystring'),
|
||||||
crypto= require('crypto'),
|
crypto= require('crypto'),
|
||||||
https= require('https'),
|
https= require('https'),
|
||||||
|
http= require('http'),
|
||||||
URL= require('url'),
|
URL= require('url'),
|
||||||
OAuthUtils= require('./_utils');
|
OAuthUtils= require('./_utils');
|
||||||
|
|
||||||
@ -28,9 +29,17 @@ exports.OAuth2.prototype._getAccessTokenUrl= function() {
|
|||||||
|
|
||||||
exports.OAuth2.prototype._request= function(method, url, headers, post_body, access_token, callback) {
|
exports.OAuth2.prototype._request= function(method, url, headers, post_body, access_token, callback) {
|
||||||
|
|
||||||
|
var http_library= https;
|
||||||
var creds = crypto.createCredentials({ });
|
var creds = crypto.createCredentials({ });
|
||||||
var parsedUrl= URL.parse( url, true );
|
var parsedUrl= URL.parse( url, true );
|
||||||
if( parsedUrl.protocol == "https:" && !parsedUrl.port ) parsedUrl.port= 443;
|
if( parsedUrl.protocol == "https:" && !parsedUrl.port ) {
|
||||||
|
parsedUrl.port= 443;
|
||||||
|
}
|
||||||
|
|
||||||
|
// As this is OAUth2, we *assume* https unless told explicitly otherwise.
|
||||||
|
if( parsedUrl.protocol != "https:" ) {
|
||||||
|
http_library= http;
|
||||||
|
}
|
||||||
|
|
||||||
var realHeaders= {};
|
var realHeaders= {};
|
||||||
if( headers ) {
|
if( headers ) {
|
||||||
@ -72,7 +81,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) {
|
response.on("data", function (chunk) {
|
||||||
result+= chunk
|
result+= chunk
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user