What is the correct method for calculating the Content-length header in node.js
Content-Length header must be the count of octets in the response body. payload.length
refers to string length in characters. Some UTF-8 characters contain multiple bytes. The better way would be to use Buffer.byteLength(string, [encoding])
from http://nodejs.org/api/buffer.html. It's a class method so you do not have to create any Buffer instance.