Fix parsing when messages contain UTF-8.

idxTerminator was an offset in characters, which was then incorrectly
used as byte offset when slicing the buffer.

Now, we look for the header terminator in the buffer, and postpone
string decoding until after we've sliced.
Process data until buffer exhausted.

In theory, multiple messages could arrive in a single _write. This
simply wraps the logic in an infinite loop, because there was already
code in place to short-circuit when done.