Added option to allow caller to control if response is ended or not.

Adding option to the template function to allow the caller to specify the response should be written to, but not sent yet.