exceptionless / Exceptionless.JavaScript

Exceptionless JavaScript client
http://exceptionless.com
Apache License 2.0
59 stars 24 forks source link

Update 'Content-Length' value for fix characters missing #65

Closed EthianWong closed 7 years ago

EthianWong commented 7 years ago

In other languages (Chinese , Japanese .... ) One word maybe use two or three bytes ...

var a = "我爱你";
console.log(a.length); //3
console.log(new Buffer(a).length); //9

So you should use new Buffer for set "Content-Length" and this problem will be resolve

niemyjski commented 7 years ago

I'm trying to figure out what the core fix is here as It's broken on desktop as well (outside of Buffer)

niemyjski commented 7 years ago

Thank you for this change. I'm going to test it further and then deploy a release

niemyjski commented 7 years ago

I changed this up to use Buffer.byteLength(request.data) instead as Buffer(string).length returns the allocated memory length instead of the actual byte count

niemyjski commented 7 years ago

https://nodejs.org/api/buffer.html#buffer_class_method_buffer_bytelength_string_encoding

niemyjski commented 7 years ago

This has been deployed (https://github.com/exceptionless/Exceptionless.JavaScript/releases/tag/v1.4.2) Thank you for your contributions!

EthianWong commented 7 years ago

You're welcome~ This is my first time to contributions in github~ make me exciting

niemyjski commented 7 years ago

We greatly appreciate it and would love to have you apart of our community :). Please feel free to hang out and chat with other developers on our slack channel: slack.exceptionless.com