I am defining the Content-Length of an HTTP request but because sometimes it might contain chinese characters when it gets to the response side of things, it gets truncated.
I have been trying to get the right way to set the content-length of a mixed Chinese/Latin String but with no luck. it keeps getting truncated.
headers["Content-Length"] = data.length; //fails
{ \"query\": \"周杰伦\", \"type\": \"artist\"} //gets truncated
{ \"query\": \"gennaro\", \"type\": \"artist\"} //successful request
Can anyone suggest how to calculate the second string length for the content-length header properly?
NOTE: the body is stringified from JSON before it is sent over.
Thanks