php-fig/fig-standards — pull request #318 by weierophinney (2014-08-27 14:55:45+00:00)
Title: Proposed additions to ResponseInterface API

Adds:

- `write($data)`
- `end($data = null)`
- `isComplete()`

These methods are defined in the [node http.ServerResponse implementation](http://nodejs.org/api/http.html#http_class_http_serverresponse). `write()` is primarily a convenience method so that you do not need to access the underlying stream; considering the most common use case when using a response is to provide the response content, making this a first-class citizen simplifies the API for end-users.

`end()` is interesting for several reasons:

- Requests handlers can indicate that the response is "complete", and should not be changed further.
- Dispatchers can test against `isComplete()` to determine if further work can/should be done.
- HTTP clients can use this to indicate response readiness so that consumers know they can now parse the response.

In node, these functionalities are used by many frameworks for the reasons stated above, including Connect, ExpressJS, Hapi, and node's own `http.request`.