spring-cloud / spring-cloud/spring-cloud-gateway
Webflux: GATEWAY_ORIGINAL_REQUEST_URL_ATTR not set in ForwardRoutingFilter
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 4.9k
- Forks
- 3.5k
- Avg merge
- 20h 57m
- Merged PRs (30d)
- 8
Description
This is a re-report of https://github.com/spring-cloud/spring-cloud-gateway/issues/3510.
Describe the bug
The documentation for Forward Routing Filter states:
The unmodified original URL is appended to the list in the ServerWebExchangeUtils.GATEWAY_ORIGINAL_REQUEST_URL_ATTR attribute
This is not the case, or I am misunderstsanding. The controller eventually handling the request (i.e. the one being forwarded to) does not see this attribute on the ServerWebExchange.
Sample
I have attached a minimal application that recreates the behavior.
It consists roughly of:
# application.yaml
spring:
cloud:
gateway:
server:
webflux:
routes:
- id: test
uri: forward:/internal/test
predicates:
- Path=/test/**
- Method=GET
@GetMapping("/internal/test")
public TestResponse test(ServerWebExchange exchange) {
Set<URI> originalUris = exchange.getAttribute(ServerWebExchangeUtils.GATEWAY_ORIGINAL_REQUEST_URL_ATTR);
return new TestResponse(true, originalUris);
}
and a test expecting the response to contain a non-null originalUris value.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run the attached minimal application and start by tracing ForwardRoutingFilter with the documented GATEWAY_ORIGINAL_REQUEST_URL_ATTR behavior in mind. Compare the exchange seen by the forwarded controller with the issue's expected test result; done means the controller observes a non-null original URI attribute as documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring, spring-boot
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100