Skip to content

Commit

Permalink
Use Buffer.byteLength instead of string length for Content-Length header
Browse files Browse the repository at this point in the history
This prevents Content-Length mismatches when sending multi-byte characters.

See https://groups.google.com/forum/?fromgroups=#!topic/nodejs/LAxACfj5_KI.
  • Loading branch information
joshisa committed Dec 23, 2013
1 parent c6c960e commit bfcfbbd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/monitor.js
Expand Up @@ -182,7 +182,7 @@ Monitor.prototype.createPing = function(error, check, timestamp, time, details,
options.method = 'POST'; options.method = 'POST';
options.headers = { options.headers = {
'Content-Type': 'application/x-www-form-urlencoded', 'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': postData.length 'Content-Length': Buffer.byteLength(postData)
}; };
this.applyApiHttpOptions(options); this.applyApiHttpOptions(options);
var self = this; var self = this;
Expand Down

0 comments on commit bfcfbbd

Please sign in to comment.