node-http-proxy
node-http-proxy copied to clipboard
FIX: Don't break on invalid headers
Have found that in some scenarios the proxied server does return invalid characters in the headers, like here: https://github.com/nodejs/node/issues/21509
In the current version the proxy does break when a invalid character is found with a
[ERR_INVALID_CHAR]: Invalid character in header content
This PR aims to avoid the total crash of the application and instead show a warning in the console and process all what can be processed.
The build seems to be breaking because of something I haven't changed... π€·ββ
Thanks @asbermudez This looks reasonable enough to me. The fail in CI is only during the Node 6 pipeline...but it's past due that Node 6 support is killed off, in my opinion.
To add some more info, this error specially happens with proxied requests to servers "protected" with Incapsula. Apparently they do use that invalid character to prevent bots from parsing the page by generating this exception with it.
@jsmylnycky I've added the changes of https://github.com/http-party/node-http-proxy/pull/1397/files to verify it does build properly.
Codecov Report
Merging #1395 into master will decrease coverage by
0.26%. The diff coverage is66.66%.
@@ Coverage Diff @@
## master #1395 +/- ##
==========================================
- Coverage 92.35% 92.08% -0.27%
==========================================
Files 6 6
Lines 314 316 +2
==========================================
+ Hits 290 291 +1
- Misses 24 25 +1
| Impacted Files | Coverage Ξ | |
|---|---|---|
| lib/http-proxy/passes/web-outgoing.js | 98.07% <66.66%> (-1.93%) |
:arrow_down: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Ξ = absolute <relative> (impact),ΓΈ = not affected,? = missing dataPowered by Codecov. Last update 9bbe486...b30ecfd. Read the comment docs.
Hello, when this PR will be merged?
As we are having the same exact issue and this PR addresses it.
The issue is related to the response from Incapsula CDN. We do not want to remove this header as it protects from some bots. We already using --insecure-http-parser and fetch is working as expected. But unfortunately proxy is not working.
Hello! Do we have any plans to merge it? We are having a problem with security scanner, it's sending malformed headers and we are getting a storm of exceptions. It's should work more graceful.
Hello! Do you have any plans to merge it?
We have the same problems
we've also run into this problem, and we are now applying the fix from this PR via patch-package.
would be good to see this merged sometime, thank you π
@jsmylnycky I was running into this issue and would wish a flag to disable this exception for invalid headers (or this got merged somehow )
@jsmylnycky I was running into this issue and would wish a flag to disable this exception for invalid headers (or this got merged somehow )
Apologies but I'm no longer involved in this project. You'll need to reach out to the current maintainers.