Skip to content

Commit

Permalink
Use Buffer.byteLength(data); to set request content length
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisHubinger committed Sep 15, 2014
1 parent 83a8a04 commit 38d6f52
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/paypal-adaptive.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function httpsPost(options, callback) {

var data = (typeof options.data !== 'string') ? JSON.stringify(options.data) : options.data;

options.headers['Content-Length'] = data.length;
options.headers['Content-Length'] = Buffer.byteLength(data);

var req = https.request(options);

Expand Down Expand Up @@ -123,10 +123,10 @@ Paypal.prototype.callApi = function (apiMethod, data, callback) {
}
};

if (config.sandboxEmailAddress)
if (config.sandboxEmailAddress)
options.headers['X-PAYPAL-SANDBOX-EMAIL-ADDRESS'] = config.sandboxEmailAddress;
if (config.deviceIpAddress)

if (config.deviceIpAddress)
options.headers['X-PAYPAL-DEVICE-IPADDRESS'] = config.deviceIpAddress;

httpsPost(options, function (error, response) {
Expand Down Expand Up @@ -242,4 +242,4 @@ adaptiveAccountsMethods.forEach(function (method) {
};
});

module.exports = Paypal;
module.exports = Paypal;

0 comments on commit 38d6f52

Please sign in to comment.