Repository navigation
Allow optional RewriteLocationResponseHeader arguments in server-webmvc - #4315
Open
sharanggupta wants to merge 1 commit into
Open
sharanggupta wants to merge 1 commit into
sharanggupta wants to merge 1 commit into
Conversation
Configuring the filter from properties with any argument omitted, e.g. the documented `RewriteLocationResponseHeader=AS_IN_REQUEST, Location, ,` or the bare `RewriteLocationResponseHeader`, failed at startup with "Unable to find operation ... rewriteLocationResponseHeader". The only shortcut method took all four arguments as Strings, and operation matching requires the argument count to equal the parameter count, so trailing empty shortcut tokens (dropped during tokenization) and named-argument subsets had nothing to bind to. Expose the filter through a @configurable shortcut that binds the arguments onto RewriteLocationResponseHeaderConfig, the same way the Retry and CircuitBreaker filters accept optional arguments. Positional shortcuts of any length, the no-argument form and arbitrary named subsets now resolve, while the four-String method is kept as is. A blank hostValue, such as an empty `hostValue:` named argument, now counts as not set and falls back to the request Host header instead of replacing the host with an empty string. Also align the docs with the real parameter names. Fixes spring-cloudgh-3729 Signed-off-by: Sharang Gupta <sharang@sharanggupta.dev>
sharanggupta
force-pushed
the
gh-3729-rewrite-location-response-header-shortcut
branch
from
October 6, 2026 21:04
91253a6 to
f8eb227
Compare
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes gh-3729
Configuring
RewriteLocationResponseHeaderfrom properties with any argument omitted — including the form documented on the filter's page,RewriteLocationResponseHeader=AS_IN_REQUEST, Location, ,, the bareRewriteLocationResponseHeader, orname/argswith a subset of the parameters — failed at startup withUnable to find operation ... rewriteLocationResponseHeader with args {_genkey_0=AS_IN_REQUEST, _genkey_1=Location}.The only shortcut for the filter took all four arguments as Strings, and operation matching requires the argument count to equal the parameter count; empty trailing shortcut tokens are dropped during tokenization, so nothing matched.
This exposes the filter through a
@Shortcut/@Configurablemethod bound toRewriteLocationResponseHeaderConfig, the same wayRetryandCircuitBreakeraccept optional arguments. Positional shortcuts of any length, the no-argument form and arbitrary named subsets now resolve; the existing four-String method is unchanged and still handles the full positional form. The docs page is aligned with the real parameter names (stripVersion,protocolsRegex) and shows the named-argument form.A blank
hostValue, such as an emptyhostValue:named argument (the case raised in the issue), now counts as not set and falls back to the requestHostheader instead of replacing the host with an empty string.Tests:
RewriteLocationResponseHeaderPropertiesTests(no Testcontainers needed) covers trailing-empty shortcut, no-arg shortcut, named subset, blankhostValue, and the full four-argument form../mvnw -pl spring-cloud-gateway-server-webmvc verifyis green locally for the non-Docker tests, javaformat and checkstyle.Note: #3886 addresses the same issue via 1–3 String overloads; this takes the config-binding approach instead so that named subsets such as
stripVersion+protocolsRegexalso work andAS_IN_REQUEST, Location, , https?is not misread as a host value. Happy to defer if the maintainers prefer that PR.