Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
pj892031 committed Jan 24, 2025
1 parent c6c7c0a commit a6b7a15
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.http.server.reactive.AbstractServerHttpRequest;
import org.springframework.http.server.reactive.ServerHttpRequestDecorator;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.WebFilter;
Expand All @@ -27,8 +28,18 @@
@Component
public class RequestAttributesProvider implements WebFilter, GlobalFilter, Ordered {

private <R> R getRequest(ServerWebExchange exchange) {
Object request = exchange.getRequest();
while (request instanceof ServerHttpRequestDecorator) {
Object delegatedRequest = ((ServerHttpRequestDecorator) request).getDelegate();
if (request == delegatedRequest) break;
request = delegatedRequest;
}
return (R) request;
}

private void copyAttributes(ServerWebExchange exchange) {
AbstractServerHttpRequest request = (AbstractServerHttpRequest) exchange.getRequest();
AbstractServerHttpRequest request = getRequest(exchange);
RequestFacade requestFacade;
try {
requestFacade = request.getNativeRequest();
Expand Down Expand Up @@ -56,7 +67,7 @@ public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {

@Override
public int getOrder() {
return Ordered.HIGHEST_PRECEDENCE;
return Ordered.HIGHEST_PRECEDENCE + 1;
}

}

0 comments on commit a6b7a15

Please sign in to comment.