Open WhiteyDude opened 5 years ago
Node v12 has a new parser that is more strict with header validation, which can cause the HPE_INVALID_HEADER_TOKEN errors.
A temporary solution is to use the --http-parser=legacy option in node's command line, or in the NODE_OPTIONS environment variable.
Either
node --http-parser=legacy index.js
or
export NODE_OPTIONS=--http-parser=legacy
node index.js
When calling a certain site (https://tickets.wbstudiotour.co.uk/webstore/shop/ViewItems.aspx?CG=HPTST2&C=TIX2), I get thrown a
HPE_INVALID_HEADER_TOKEN
error. Further investigation shows this site is sending back a Server header with no colon or value.Some digging lead me to find https://github.com/creationix/http-parser-js, which appears to resolve this issue by monkey patching in a different
HTTPParser
to the relevant binding:process.binding('http_parser').HTTPParser = require('http-parser-js').HTTPParser;
However this monkey patch doesn't seem to change anything for me in request-promise. I'm unsure if request-promise maybe doesn't use this parser, or has its own custom parser?