tntim96/JSCover — pull request #129 by ajaxsys (2014-05-01 06:47:16+00:00)
Title: Fix Content-Length return wrong length

Hi, thanks for creating this awesome tool. I got a bug when using JSCover.

In Proxy mode, Content-Length return wrong length in some Unicode cases.

For example:
"小方".length() // Output: 2
"小方".getBytes("UTF-8").length // Output: 6

As `Content-Length` defines the size of the body,
in above case `data.length()` always return the shorter length,
so ***the browser will cut the left JavaScript code*** that causes syntax errors.
(Tested in chrome/Firefox).

Change to `data.getBytes().length`, parsing with bytes using the platform's default charset,
will get correct length.

*Content-Length Reference: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.13