Skip to content

Treat a blank hostValue as unset in RewriteLocationResponseHeader - #4317

Open
sharanggupta wants to merge 1 commit into
spring-cloud:mainfrom
sharanggupta:gh-blank-host-value-webflux-parity
Open

sharanggupta wants to merge 1 commit into
spring-cloud:mainfrom
sharanggupta:gh-blank-host-value-webflux-parity

Conversation

@sharanggupta

Copy link
Copy Markdown

Fixes gh-4316

The server-webflux RewriteLocationResponseHeaderGatewayFilterFactory only checked hostValue for null, so a blank value (e.g. an empty hostValue: named argument) replaced the host:port portion of the Location header with an empty string, producing https:///some/object/id.

This change falls back to the request Host header whenever hostValue has no text (StringUtils.hasText), matching the server-webmvc filter (#4315), adds a unit test for the blank case, and documents the blank fallback on the webflux filter page.

Verified with ./mvnw -pl spring-cloud-gateway-server-webflux test -Dtest='RewriteLocation*' (16 tests, 0 failures) and ./mvnw -pl spring-cloud-gateway-server-webflux validate (javaformat + checkstyle).

The server-webflux RewriteLocationResponseHeaderGatewayFilterFactory
only checked config.getHostValue() for null, so a blank value, such as
an empty `hostValue:` named argument in application.yml, replaced the
host:port portion of the Location header with an empty string and
produced URLs like `https:///some/object/id`.

Fall back to the request Host header whenever hostValue has no text,
matching the server-webmvc filter (see spring-cloudgh-4315), and document the blank
case on the webflux filter page.

Fixes spring-cloudgh-4316

Signed-off-by: Sharang Gupta <sharang@sharanggupta.dev>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RewriteLocationResponseHeader (server-webflux) replaces the host with an empty string when hostValue is blank

2 participants