Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Nagy <ronagy@icloud.com>2020-09-20 10:32:06 +0300
committerRobert Nagy <ronagy@icloud.com>2020-10-10 11:11:41 +0300
commitd70c0ed250ac79e267e87213c6fa0a6c51a634af (patch)
treea708c96d57151b2b27f9f67d8547fd6f1e12fb2f /doc/api/http.md
parent8d8e06a345043bec787e904edc9a2f5c5e9c275f (diff)
http: allow passing array of key/val into writeHead
Enables an optimization when the user already has the headers in an array form, e.g. when proxying. PR-URL: https://github.com/nodejs/node/pull/35274 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'doc/api/http.md')
-rw-r--r--doc/api/http.md10
1 files changed, 9 insertions, 1 deletions
diff --git a/doc/api/http.md b/doc/api/http.md
index a63e0a0c1b2..ac92b34b30b 100644
--- a/doc/api/http.md
+++ b/doc/api/http.md
@@ -1797,6 +1797,9 @@ 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/35274
+ description: Allow passing headers as an array.
- version:
- v11.10.0
- v10.17.0
@@ -1813,7 +1816,7 @@ changes:
* `statusCode` {number}
* `statusMessage` {string}
-* `headers` {Object}
+* `headers` {Object|Array}
* Returns: {http.ServerResponse}
Sends a response header to the request. The status code is a 3-digit HTTP
@@ -1821,6 +1824,11 @@ status code, like `404`. The last argument, `headers`, are the response headers.
Optionally one can give a human-readable `statusMessage` as the second
argument.
+`headers` may be an `Array` where the keys and values are in the same list.
+It is *not* a list of tuples. So, the even-numbered offsets are key values,
+and the odd-numbered offsets are the associated values. The array is in the same
+format as `request.rawHeaders`.
+
Returns a reference to the `ServerResponse`, so that calls can be chained.
```js