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.
如果标头没有先前的值,则相当于调用 response.setHeader()
。
¥If there were no previous values for the header, this is equivalent to calling
response.setHeader()
.
尝试设置包含无效字符的标头字段名称或值将导致抛出 TypeError
。
¥Attempting to set a header field name or value that contains invalid characters
will result in a TypeError
being thrown.
// 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');
});