brettlangdon / node-dogapi

Datadog API Node.JS Client
https://brettlangdon.github.io/node-dogapi/
105 stars 45 forks source link

Use Buffer.byteLength to get Content-Length #44

Closed jupemara closed 8 years ago

jupemara commented 8 years ago

Hi, @brettlangdon I'm sorry that this topic is unfamiliar for english-speaking people. When created new datadog event, I've gotten following error.

<Invalid JSON structure>

I think this cause is that this library uses String.length. See example.

> '☆'.length
1
> Buffer.byteLength('☆')
3

So datadog server considers to Content-Length is shorter than real body size, and failed to parse POST body. thanks.

brettlangdon commented 8 years ago

@JumpeiArashi, thank you for the pull request. The problem and your explanation makes sense :+1:

I will merge and deploy right away.

brettlangdon commented 8 years ago

The version 2.3.0 is now published with these changes.

jupemara commented 8 years ago

Thank you for merging. We'll keep your library user :metal: