有没有办法检查使用 node/express 2.x 发送了哪些特定的标头?
我的文件下载在大多数情况下都能完美运行,但在某些特定情况下,我在 Chrome 中遇到错误(节点中没有错误):
Duplicate headers received from server
The response from the server contained duplicate headers. This problem is generally the result of a misconfigured website or proxy. Only the website or proxy administrator can fix this issue.
Error 349 (net::ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION): Multiple distinct Content-Disposition headers received. This is disallowed to protect against HTTP response splitting attacks.
出于测试目的,我想查看是否已发送特定标头,有没有办法使用 node.js 执行此操作?
...而且因为有人会问我用于设置标头的代码,所以我将流作为下载管道,并且只在一个位置设置标头。
res.setHeader('Content-disposition', 'attachment; filename=' + filename)
res.setHeader('Content-Length', stats.size)
res.setHeader('Content-type', 'application/pdf')
stream.pipe(res)