【发布时间】:2020-09-14 13:14:32
【问题描述】:
我有一个 NodeJS 代码,它使用 https 模块作为:https.request(options, (res) => {...... 其中options 是一个类似的对象
const options = {
hostname: SERVICE_HOSTNAME,
path: BASE_PATH,
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
ApplicationId,
Authorization
}
};
当我添加 Accept 标头时,我的问题就开始了。我收到一个错误:
TypeError [ERR_INVALID_HTTP_TOKEN]: Header name must be a valid HTTP token ["Accept"]
at ClientRequest.setHeader (_http_outgoing.js:472:3)
at new ClientRequest (_http_client.js:203:14)
at Object.request (https.js:289:10)
Accept 标头如何无效?
【问题讨论】:
标签: node.js https request http-headers