Merge branch 'broox-oauth2_put'
Conflicts: tests/oauth2.js
This commit is contained in:
@ -49,19 +49,25 @@ exports.OAuth2.prototype.buildAuthHeader= function(token) {
|
||||
return this._authMethod + ' ' + token;
|
||||
};
|
||||
|
||||
exports.OAuth2.prototype._chooseHttpLibrary= function( parsedUrl ) {
|
||||
var http_library= https;
|
||||
// As this is OAUth2, we *assume* https unless told explicitly otherwise.
|
||||
if( parsedUrl.protocol != "https:" ) {
|
||||
http_library= http;
|
||||
}
|
||||
return http_library;
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// As this is OAUth2, we *assume* https unless told explicitly otherwise.
|
||||
if( parsedUrl.protocol != "https:" ) {
|
||||
http_library= http;
|
||||
}
|
||||
var http_library= this._chooseHttpLibrary( parsedUrl );
|
||||
|
||||
|
||||
var realHeaders= {};
|
||||
for( var key in this._customHeaders ) {
|
||||
@ -133,7 +139,7 @@ exports.OAuth2.prototype._executeRequest= function( http_library, options, post_
|
||||
callback(e);
|
||||
});
|
||||
|
||||
if( options.method == 'POST' && post_body ) {
|
||||
if( (options.method == 'POST' || options.method == 'PUT') && post_body ) {
|
||||
request.write(post_body);
|
||||
}
|
||||
request.end();
|
||||
|
||||
Reference in New Issue
Block a user