Merge branch 'merging_body_length_fix'
This commit is contained in:
commit
cb6e4ea3b8
@ -6,14 +6,11 @@ Tested against Twitter (http://twitter.com), term.ie (http://term.ie/oauth/examp
|
||||
|
||||
Also provides rudimentary OAuth2 support, tested against facebook connect and github. For more complete usage examples please take a look at connect-auth (http://github.com/ciaranj/connect-auth)
|
||||
|
||||
If you're running a node.js version more recent than 0.4 then you will need to use a version of node-oauth greater than or equal to 0.9.0.
|
||||
If you're running a node.js version in the 0.2x stable branch, then you will need to use version 0.8.4.
|
||||
|
||||
Please be aware that when moving from 0.8.x to 0.9.0 there are no major API changes your, I've bumped the semi-major version element
|
||||
so that I can release fixes to the 0.8.x stream if problems come out.
|
||||
|
||||
Change History
|
||||
==============
|
||||
|
||||
* 0.9.2 - Correct content length calculated for non-ascii post bodies (Thanks selead)
|
||||
* 0.9.1 - Added support for automatically following 302 redirects (Thanks neyric) Added support for OAuth Echo (Thanks Ryan LeFevre). Improved handling of 2xx responses (Thanks Neil Mansilla).
|
||||
* 0.9.0 - Compatibility fixes to bring node-oauth up to speed with node.js 0.4x [thanks to Rasmus Andersson for starting the work ]
|
||||
* 0.8.4 - Fixed issue #14 (Parameter ordering ignored encodings). Added support for repeated parameter names. Implements issue #15 (Use native SHA1 if available, 10x speed improvement!). Fixed issue #16 (Should use POST when requesting access tokens.). Fixed Issue #17 (OAuth2 spec compliance). Implemented enhancement #13 (Adds support for PUT & DELETE http verbs). Fixes issue #18 (Complex/Composite url arguments [thanks novemberborn])
|
||||
|
@ -325,7 +325,7 @@ exports.OAuth.prototype._performSecureRequest= function( oauth_token, oauth_toke
|
||||
post_body= querystring.stringify(extra_params);
|
||||
}
|
||||
|
||||
headers["Content-length"]= post_body ? post_body.length : 0; //Probably going to fail if not posting ascii
|
||||
headers["Content-length"]= post_body ? Buffer.byteLength(post_body) : 0;
|
||||
headers["Content-Type"]= post_content_type;
|
||||
|
||||
var path;
|
||||
|
@ -1,6 +1,6 @@
|
||||
{ "name" : "oauth"
|
||||
, "description" : "Library for interacting with OAuth 1.0, 1.0A, 2 and Echo. Provides simplified client access and allows for construction of more complex apis and OAuth providers."
|
||||
, "version" : "0.9.1"
|
||||
, "version" : "0.9.2"
|
||||
, "directories" : { "lib" : "./lib" }
|
||||
, "main" : "index.js"
|
||||
, "author" : "Ciaran Jessup <ciaranj@gmail.com>"
|
||||
|
@ -306,6 +306,36 @@ vows.describe('OAuth').addBatch({
|
||||
}
|
||||
},
|
||||
'if the post_body is a string' : {
|
||||
"and it contains non ascii (7/8bit) characters" : {
|
||||
"the content length should be the byte count, and not the string length" : function(oa) {
|
||||
var testString= "Tôi yêu node";
|
||||
var testStringLength= testString.length;
|
||||
var testStringBytesLength= Buffer.byteLength(testString);
|
||||
assert.notEqual(testStringLength, testStringBytesLength); // Make sure we're testing a string that differs between byte-length and char-length!
|
||||
|
||||
var op= oa._createClient;
|
||||
try {
|
||||
var callbackCalled= false;
|
||||
oa._createClient= function( port, hostname, method, path, headers, sshEnabled ) {
|
||||
assert.equal(headers["Content-length"], testStringBytesLength);
|
||||
return {
|
||||
write: function(data){
|
||||
callbackCalled= true;
|
||||
assert.equal(data, testString);
|
||||
},
|
||||
on: function() {},
|
||||
end: function() {
|
||||
}
|
||||
};
|
||||
}
|
||||
var request= oa.post("http://foo.com/blah", "token", "token_secret", "Tôi yêu node")
|
||||
assert.equal(callbackCalled, true);
|
||||
}
|
||||
finally {
|
||||
oa._createClient= op;
|
||||
}
|
||||
}
|
||||
},
|
||||
"and no post_content_type is specified" : {
|
||||
"It should be written as is, with a content length specified, and the encoding should be set to be x-www-form-urlencoded" : function(oa) {
|
||||
var op= oa._createClient;
|
||||
|
Loading…
x
Reference in New Issue
Block a user