res.append(field [, value])

中英双语

Express v4.11.0+ 支持 res.append()

将指定的 value 附加到 HTTP 响应标头 field。如果尚未设置标头,则会创建具有指定值的标头。value 参数可以是字符串或数组。

注意:在 res.append() 之后调用 res.set() 会重置之前设置的 header 值。

res.append('Link', ['<http://localhost/>', '<http://localhost:3000/>'])
res.append('Set-Cookie', 'foo=bar; Path=/; HttpOnly')
res.append('Warning', '199 Miscellaneous warning')