-
Notifications
You must be signed in to change notification settings - Fork 73
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
feat(core): lower case http headers, based on env variable. Fixes #311 #318
Conversation
Change is only validated using the automated test cases. |
Codecov Report
@@ Coverage Diff @@
## master #318 +/- ##
==========================================
+ Coverage 95.41% 95.72% +0.31%
==========================================
Files 157 164 +7
Lines 2769 3137 +368
Branches 366 431 +65
==========================================
+ Hits 2642 3003 +361
- Misses 123 129 +6
- Partials 4 5 +1
Continue to review full report at Codecov.
|
Thanks for creating this PR. I'll try to check it tomorrow! 🙌 |
@alexanderbartels Finally found some time for reviewing it, sorry for the late response. Before I'll dig more into the details, I have one general question. Why do you think it is needed to memoize this operation. Reading from |
} | ||
|
||
// lower case header | ||
const lowerCasedHeaders = {}; |
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 would extract this process to separate function, eg. #normalizeHeaders
- then you can use simple ternary check. If we care here about the performance impact then it can stay as it is, but if not it would be better to use reduce
instead of forEach
. In typical case the total number of outgoing headers won't reach more than 10.
not sure if its still a problem but here are some references: cite from https://expressjs.com/en/advanced/best-practice-performance.html
and from node issues: nodejs/node#3104
As we hope to get a lot of traffic it might be still a good idea to cache it. But to be really sure if it is still an issue, a performance test would be needed. |
@alexanderbartels Ok, you convinced me! 🙃 |
@alexanderbartels regarding testing - you can write simple integration/E2E scenarios directly inside |
@alexanderbartels any updates? If not I'll take it over. I'm planning to introduce it in next major version 4.0 |
1e2fc60
to
bd23088
Compare
@alexanderbartels could you sync your PR with |
Duplicates: #349 |
PR Type
Lower Case HTTP Headers behind a Feature Flag as discussed in #311
What is the current behavior?
Issue Number: #311
What is the new behavior?
all http headers are lower cased if the env flag is defined.
Does this PR introduce a breaking change?
Other information
Just a first draft. as the flag is based on the env flag and it seems to be a good idea to cache the value for performance reason i had no idea how to test with and without the flag.
I can continue after some general feedback.