summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorMark S. Everitt <mark.s.everitt@gmail.com>2019-02-06 22:17:23 +0000
committerAnna Henningsen <anna@addaleax.net>2019-02-09 16:34:09 +0100
commitf93df511558609fad38fe0ae34635c7c914ad2f8 (patch)
tree1a51de6dfc339607b9810ec640873f611df5a805 /doc
parentc2d374fcccf04b6bf62acabe09647fb4fab2dab8 (diff)
downloadandroid-node-v8-f93df511558609fad38fe0ae34635c7c914ad2f8.tar.gz
android-node-v8-f93df511558609fad38fe0ae34635c7c914ad2f8.tar.bz2
android-node-v8-f93df511558609fad38fe0ae34635c7c914ad2f8.zip
http: makes response.writeHead return the response
Fixes: https://github.com/nodejs/node/issues/25935 PR-URL: https://github.com/nodejs/node/pull/25974 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Diffstat (limited to 'doc')
-rw-r--r--doc/api/http.md16
1 files changed, 13 insertions, 3 deletions
diff --git a/doc/api/http.md b/doc/api/http.md
index 8803078569..87de5a9bba 100644
--- a/doc/api/http.md
+++ b/doc/api/http.md
@@ -1450,6 +1450,10 @@ the request body should be sent. See the [`'checkContinue'`][] event on
<!-- YAML
added: v0.1.30
changes:
+ - version: REPLACEME
+ pr-url: https://github.com/nodejs/node/pull/25974
+ description: Return `this` from `writeHead()` to allow chaining with
+ `end()`.
- version: v5.11.0, v4.4.5
pr-url: https://github.com/nodejs/node/pull/6291
description: A `RangeError` is thrown if `statusCode` is not a number in
@@ -1459,17 +1463,23 @@ changes:
* `statusCode` {number}
* `statusMessage` {string}
* `headers` {Object}
+* Returns: {http.ServerResponse}
Sends a response header to the request. The status code is a 3-digit HTTP
status code, like `404`. The last argument, `headers`, are the response headers.
Optionally one can give a human-readable `statusMessage` as the second
argument.
+Returns a reference to the `ServerResponse`, so that calls can be chained.
+
```js
const body = 'hello world';
-response.writeHead(200, {
- 'Content-Length': Buffer.byteLength(body),
- 'Content-Type': 'text/plain' });
+response
+ .writeHead(200, {
+ 'Content-Length': Buffer.byteLength(body),
+ 'Content-Type': 'text/plain'
+ })
+ .end(body);
```
This method must only be called once on a message and it must