Nodejs请求:HPE_INVALID_HEADER_TOKEN [英] Nodejs request: HPE_INVALID_HEADER_TOKEN
问题描述
我使用 request
模块在某个页面上收到 HPE_INVALID_HEADER_TOKEN
。根据我在Google上发现的情况,这是由服务器响应错误/格式错误引起的,但后者不在我的控制之下。我可以配置请求忽略无效的标题,或者只是给我整个原始响应进行处理吗?
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?
推荐答案
解决方案是这个库: https://www.npmjs.com/package/http-parser-js
The solution is this library: https://www.npmjs.com/package/http-parser-js
所以要解决你的问题:
-
npm install http- parser-js
npm install http-parser-js
在require('request')之前添加此代码
Add this code before require('request')
process.binding('http_parser').HTTPParser = require('http-parser-js').HTTPParser;
这篇关于Nodejs请求:HPE_INVALID_HEADER_TOKEN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!