-
Notifications
You must be signed in to change notification settings - Fork 566
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
Broad changes to handle case properly in headers and parameters #5221
Merged
tjquinno
merged 7 commits into
helidon-io:helidon-3.x
from
tjquinno:fix-case-simple-3.x
Oct 31, 2022
Merged
Broad changes to handle case properly in headers and parameters #5221
tjquinno
merged 7 commits into
helidon-io:helidon-3.x
from
tjquinno:fix-case-simple-3.x
Oct 31, 2022
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
oracle-contributor-agreement
bot
added
the
OCA Verified
All contributors have signed the Oracle Contributor Agreement.
label
Oct 20, 2022
tjquinno
requested review from
tomas-langer,
romain-grecourt,
Verdent,
danielkec and
spericas
October 20, 2022 15:19
…f Headers-based factory method
romain-grecourt
previously approved these changes
Oct 24, 2022
…eaders instead of deprecating the methods and adding new pre-deprecated methods
tomas-langer
approved these changes
Oct 31, 2022
* @return new instance with specified initial content | ||
* @deprecated Use {@link #create(Headers)} instead, passing {@code Headers} instead of {@code Parameters}. | ||
*/ | ||
@Deprecated(since = "3.0.3", forRemoval = true) |
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.
No need to deprecate, 4.0.0 will not use this class at all
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
3.x
Issues for 3.x version branch
OCA Verified
All contributors have signed the Oracle Contributor Agreement.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #5149
Header names should be case-insensitive. What Helidon calls "parameters" (query parameter, path params) should be case-sensitive. (Note that our use of "parameters" in this context does not correspond to other usages such as https://httpwg.org/specs/rfc9110.html#parameter, in which a parameter is an optional addition to the value of a "field"--basically, an addition to a header value.)
This PR fixes problems in both headers and parameters.
I tried to be fairly minimally-invasive as possible while still addressing the problems. Still, there are quite a few changes needed to fix this situation.
Some highlights:
Key changes are in
helidon-common-http
but other components are affected as well.HashHeaders
extendsHashParameters
. Each now creates the correct type ofMap
(case-sensitive or -insensitive) in separate protected factory methods. Various classes related to writeable headers now extendHashHeaders
(instead of extendingHashParameters
as they did before) and so now inherit the correct case-insensitive behavior.ReadOnlyHeaders
extendsReadOnlyParameters
. Each now creates the correct type ofMap
in protected factory methods for various purposes. Various classes related to read-only headers now extendReadOnlyHeaders
to inherit the correct case-insensitive behavior.Headers
or its various implementations rather thanParameters
or its counterparts so the data is handled in the (correct) case-insensitive manner.helidon-config-testing
now contains a newCaseSensitivityTester
utility class and is a new test-scoped dependency for several components.Some lower-level details:
Parameters
now extendsIterable<Map.Entry<String, List<String>>>
and provides a default implementation ofiterator
. Adding thisextends
reduces the need to create temporary data structures in other code. For our classes which implementParameters
, this PR includes overrides ofiterator
with more efficient code than the default.I kept some methods that the IDE shows as no longer used because, although unlikely, developers might have written extensions of our classes and overridden those methods. Removing them would be a backwards-incompatible change.
There is abundant opportunity to--but I did not--refactor further to reduce even more code duplication. For example,
Header
andParameters
could extend a common parameterized interfaceHashParameters
andHashHeaders
could extend a common abstract superclassReadOnlyParameters
andReadOnlyHeaders
But doing that refactoring would be quite a bit more far-reaching than the proposed changes here. Plus, header handling is much different in 4.x so further major refactoring work in 3.x would not carry forward and is likely not worth the investment.