不带参数设置Content-Type
Set Content-Type without parameters
Servers MUST send all JSON API data in response documents with the header Content-Type: application/vnd.api+json
without any media type parameters.
当我使用 res.set( "Content-Type", "application/vnd.api+json" );
在 express 中设置内容类型时,express 会自动在内容类型上添加 charset=utf-8
参数。这使得响应不符合规范。
我尝试使用 res.setHeader
更直接地设置 header,但结果是相同的。
如何正确设置不带参数的响应内容类型?
res.send()
是添加 charset
;你必须手动使用 res.end()
。
Servers MUST send all JSON API data in response documents with the header
Content-Type: application/vnd.api+json
without any media type parameters.
当我使用 res.set( "Content-Type", "application/vnd.api+json" );
在 express 中设置内容类型时,express 会自动在内容类型上添加 charset=utf-8
参数。这使得响应不符合规范。
我尝试使用 res.setHeader
更直接地设置 header,但结果是相同的。
如何正确设置不带参数的响应内容类型?
res.send()
是添加 charset
;你必须手动使用 res.end()
。