-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix custom-header #369
fix custom-header #369
Conversation
collector must return the result it's unclear why the test passed, when running the same code by hand did - allow colons in header values (split only on first) - log and exit when proxy cli fails to start in tests
16736b4
to
807dda7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for these changes ! 🙏 🙏
Just a small doubt around the log.error
call in collectHeadersIntoObject
bin/configurable-http-proxy
Outdated
value = value.trim(); | ||
var colon = value.indexOf(":"); | ||
if (colon <= 0) { | ||
log.error("A colon was expected in custom header: " + value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think calling log
here isn't valid. I got crashes when fidling with this part of the code to make it log using log
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Fixed and test added.
@@ -229,7 +240,7 @@ describe("CLI Tests", function () { | |||
"--custom-header", | |||
"k1: v1", | |||
"--custom-header", | |||
" k2 : v2 v2 ", | |||
" k2 : host:123 ", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe adding a test with an invalid header (eg --custom-header badheader
) would be worthwile ? I think the current error logging in collectHeadersIntoObject
crashes.
and fix undefined `log.error` in favor of `console.error`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM ! Thank you for doing all the work ! 🙏 |
collector must return the result
The test was passing because the update-in-place way we implemented the collector apparently works if you have more than one header, but not if you have only one. I don't know if that's a bug upstream or not, but the right thing to do is to return after each collection.
Additional improvements:
closes #368