Fixed for session writing before headers sent.

Added new option: write_on_add.
Writes when notifications or errors are consumed.

Signed-off-by: Guillaume Poirier-Morency <guillaumepoiriermorency@gmail.com>