Fixed HTTP chunked encoding.

Fixes #858.