Added flag to support reusing the buffer when writing chunks.
- By default websockets can't share the buffer since the underlying write action
 is queued in the task queue so make it false in the websocket scenario.
- Added unit tests.