Incrementally send data in StreamHandler.

* Use a generic output function to accumulate data.
* Chunk content output if necessary.
* Clean JSONRPC and remove unused code.