Nodejs request: HPE_INVALID_HEADER_TOKEN

2019-05-11 07:02发布

I receive HPE_INVALID_HEADER_TOKEN on a certain page using request module. From what I've found on Google, this is caused by an incorrect / malformed server response, however the latter is not under my control. Can I configure request to ignore invalid headers or just give me the whole raw response for processing?

1条回答
smile是对你的礼貌
2楼-- · 2019-05-11 07:43

The solution is this library: https://www.npmjs.com/package/http-parser-js

So to fix your problem:

  1. npm install http-parser-js

  2. Add this code before require('request')

    process.binding('http_parser').HTTPParser = require('http-parser-js').HTTPParser;
    
查看更多
登录 后发表回答