在Unirest请求标头中避免Content-Length

时间:2019-12-16 07:24:23

标签: node.js unirest

这是我的代码

unirest.post(url)
      .headers({
        'Accept': 'application/json',
        'Content-Type': 'application/json'
      })
      .auth(this.auth)
      .timeout(global.timeout)
      .send({
        'username': this.username,
        'token': this.token
      });

它总是生成content-length头。如何避免单调自动设置content-length标头?

1 个答案:

答案 0 :(得分:0)

content-length标头是保持HTTP连接的持久性所必需的。 因此最好保持自动设置。 同样,unirest没有任何手动设置内容长度的选项。