Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

body.length != Buffer.byteLength. #55

Closed
wants to merge 3 commits into from

2 participants

@saighost

One character maybe not one byte. So body.length != Buffer.byteLength.

Sorry for the second change, it only for myself. but I don't know how to remove it.

The third change is for when sever send 400 error and I need to know the info of response.statusCode.

ps : http://en.wikipedia.org/wiki/UTF-8

@saighost saighost closed this
@saighost saighost reopened this
@milewise
Collaborator

merged in the 1st and 3rd commits. thanks!

@milewise milewise closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 13, 2012
  1. @saighost

    body.length != Buffer.byteLength . Server maybe send 400 error back i…

    saighost authored
    …f body.length != Buffer.byteLength.
  2. @saighost
  3. @saighost

    add response in callback. if response.statusCode!=200, body will be u…

    saighost authored
    …ndefined and user may get the real error info form response.
This page is out of date. Refresh to see the latest.
Showing with 11 additions and 6 deletions.
  1. +2 −1  lib/client.js
  2. +1 −1  lib/http.js
  3. +8 −4 lib/wsdl.js
View
3  lib/client.js
@@ -130,7 +130,8 @@ Client.prototype._invoke = function(method, arguments, location, callback) {
var obj = self.wsdl.xmlToObject(body);
}
catch (error) {
- return callback(error, null, body);
+ // if response.statusCode!=200, body will be undefined and user may get the real error info form response.
+ return callback(error, response, body);
}
var result = obj.Body[output.$name];
// RPC/literal response body may contain element named after the method + 'Response'
View
2  lib/http.js
@@ -25,7 +25,7 @@ exports.request = function(rurl, data, callback, exheaders, exoptions) {
};
if (typeof data == 'string') {
- headers["Content-Length"] = data.length;
+ headers["Content-Length"] = Buffer.byteLength(data, 'utf8');;
headers["Content-Type"] = "application/x-www-form-urlencoded";
}
View
12 lib/wsdl.js
@@ -26,14 +26,17 @@ function splitNSName(nsName) {
function xmlEscape(obj) {
if (typeof(obj) === 'string') {
- return obj
+ if(obj.length<30){
+ return obj
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
- .replace(/'/g, '&apos;')
+ .replace(/'/g, '&apos;')
+ }else{
+ return '<![CDATA[ '+ obj +' ]]> '
+ }
}
-
return obj;
}
@@ -41,7 +44,8 @@ var trimLeft = /^[\s\xA0]+/;
var trimRight = /[\s\xA0]+$/;
function trim(text) {
- return text.replace(trimLeft, '').replace(trimRight, '');
+ //return text.replace(trimLeft, '').replace(trimRight, '');
+ return text;
}
function extend(base, obj) {
Something went wrong with that request. Please try again.