joepie91 / node-bhttp

A sane HTTP client library for Node.js with Streams2 support.
62 stars 12 forks source link

Calculate buffer length of utf-8 data for json correctly #29

Open myndzi opened 7 years ago

myndzi commented 7 years ago

Since we're explicitly calculating the utf-8 length (as far as I can tell, this is an implicit assumption overall) when encoding JSON, I made sure to add it to the Content-Type header too.

The denormalization of the content-length header is so we don't have to do the extra work of calculating the utf8-length if we don't have to.

There is no real test structure to speak of, so I just tested the failing case before and after to ensure it succeeds.

Closes https://github.com/joepie91/node-bhttp/issues/28