diff --git a/doc/api/http.md b/doc/api/http.md index e0b2c55a56a3d0..d7b77f1a4c55ad 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -2991,12 +2991,12 @@ added: * `value` {string|string\[]} Header value * Returns: {this} -Append a single header value for the header object. +Append a single header value to the header object. -If the value is an array, this is equivalent of calling this method multiple +If the value is an array, this is equivalent to calling this method multiple times. -If there were no previous value for the header, this is equivalent of calling +If there were no previous values for the header, this is equivalent to calling [`outgoingMessage.setHeader(name, value)`][]. Depending of the value of `options.uniqueHeaders` when the client request or the diff --git a/doc/api/http2.md b/doc/api/http2.md index 0b91e2b36aa267..288dccd0472ac6 100644 --- a/doc/api/http2.md +++ b/doc/api/http2.md @@ -3659,6 +3659,36 @@ message) to the response. Attempting to set a header field name or value that contains invalid characters will result in a [`TypeError`][] being thrown. +#### `response.appendHeader(name, value)` + + + +* `name` {string} +* `value` {string|string\[]} + +Append a single header value to the header object. + +If the value is an array, this is equivalent to calling this method multiple +times. + +If there were no previous values for the header, this is equivalent to calling +[`response.setHeader()`][]. + +Attempting to set a header field name or value that contains invalid characters +will result in a [`TypeError`][] being thrown. + +```js +// Returns headers including "set-cookie: a" and "set-cookie: b" +const server = http2.createServer((req, res) => { + res.setHeader('set-cookie', 'a'); + res.appendHeader('set-cookie', 'b'); + res.writeHead(200); + res.end('ok'); +}); +``` + #### `response.connection`