response.appendHeader(name, value)
name<string>value字符串|字符串数组
将单个标头值附加到标头对象。
🌐 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');
});