This makes sure that the headers are written to the output stream before the async dispatch. Otherwise we end up with strange NPEs when flushing the buffer on writing the body. fixes #715