feat: introduce konghq.com/headers-separator annotation and make parsing more robust #5977
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.
What this PR does / why we need it:
This PR resolves real-world problems reported by the user that
konghq.com/headers.*
doesn't allow to specify headers that contain,
which is permitted in header values, but can't be used because KIC uses it as a separator.HTTP specification is very permissive in terms of what is allowed as header value
https://datatracker.ietf.org/doc/html/rfc9110#name-field-values
see also Cloudflare docs.
Hence coming up with an escaping pattern for commas is hard and won't be easy to use/interpret by a user. So this PR introduces an additional annotation
konghq.com/headers-separator
that allows specifying a different separator than the default,
.Moreover, this PR makes parsing header values from
konghq.com/headers.*
more robust - now it discards leading and trailing whitespace characters so the below annotations are equivalentthis is a safe change, because according to https://datatracker.ietf.org/doc/html/rfc9110#section-5.5-3
that will make users' lives easier.
Furthermore, a test case for handling a header with an empty value has been added because it's a valid use case, see https://datatracker.ietf.org/doc/html/rfc9110#section-12.5.3-12
Which issue this PR fixes:
Closes #5427
PR Readiness Checklist:
Complete these before marking the PR as
ready to review
:CHANGELOG.md
release notes have been updated to reflect any significant (and particularly user-facing) changes introduced by this PRkonghq.com/headers-separator
annotation docs.konghq.com#7351