visionmedia/superagent — pull request #79 by noisebeuter (2012-03-06 14:17:11+00:00)
Title: Make Content-Length detection work for strings containing multibyte characters

Hi!

With the current code, the Content-Length header field gets set to a wrong (too small) value if ```this_.data``` contains multibyte characters because ```String.length``` is the length of the string in characters, whereas Content-Length should be set to the size of the content in bytes. ```Buffer.byteLength()``` should be used instead. For example:

```js
"aou".length; // => 3
Buffer.byteLength("aou"); // => 3

"äöü".length; // => 3
Buffer.byteLength("äöü"); // => 6
```