detro/ghostdriver — pull request #40 by sigwall (2012-07-22 08:33:31+00:00)
Title: Set correct length in Content-Length header

When dealing with multibyte character strings, String.length returns
length of string in characters, not in bytes. So answer is truncated:
```shell
sw@etgc ~ $ GET http://localhost:8080/session/1/title
{"sessionId":"1","status":0,"value":"Янде%
sw@etgc ~ $
```
To get byte length we encode and unescape it into one-byte
character Latin-1 encoding.

```javascript
this.setHeader("Content-Length", unescape(encodeURIComponent(body)).length);
```

NodeJS has Buffer to do that, future HTML5 spec has a Blob constructor but latest WebKit only has a deprecated WebKitBlobBuilder.