【问题标题】:Add Duplicate HTTP Response Headers in Nodejs在 Nodejs 中添加重复的 HTTP 响应标头
【发布时间】:2012-07-17 21:26:11
【问题描述】:

我正在寻找在 Nodejs 的 http 响应中添加重复的 HTTP 标头,例如:

HTTP/1.1 206 Partial Content
Content-Length: 1234567
Content-Type: video/ogg
Content-type: multipart/byteranges; boundary=THIS_STRING_SEPARATES

我使用的是Nodejs提供的http模块,当我发送响应头时,我只能定义一个“Content-Type”头:

var header = {};
header['Content-Type'] = "video/ogg";

header['Content-Type'] = "multipart/byteranges; boundary=THIS_STRING_SEPARATES";

是否可以在响应中同时包含“Content-Type”?谢谢。

【问题讨论】:

  • 我假设使用header['Content-type'](一个字母小写)不起作用?
  • 您好,感谢您的快速回复。我试图将“内容类型”和“内容类型”都放入标题中,但在客户端我只能看到最后定义的那个。

标签: node.js http-headers httpresponse


【解决方案1】:

目前,这是一个带有 Node.js 本身的 open issue。您可以通过使用一个带有逗号分隔值的 Content-Type using this patch 来规避这种情况,或者如果可能的话,实现一个 X-Content-Type 标头。多个X- 标头值当前连接为一个。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-07
    • 1970-01-01
    • 1970-01-01
    • 2011-02-24
    • 2013-02-14
    相关资源
    最近更新 更多