Node v12 has a new parser that is more strict with header validation, which can cause the same errors, especially with sites using Imperva/Incapsula that include an invalid header in HTTP 1.1 responses.
A temporary solution is to use the --http-parser=legacy
option in node's command line, or in the NODE_OPTIONS
environment variable.
Since v12.15.0
and v10.19.0
you can do this:
http.request(url, { insecureHTTPParser: true })
Additional information can be found here:
https://github.com/nodejs/node/issues/27711#issuecomment-584621376
Edit: --http-parser=legacy
is no longer supported in recent versions (including minor versions of v12). A solution for newer node versions is to use --insecure-http-parser
instead.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…