diff --git a/src/main/java/org/springframework/cloud/gateway/config/GatewayAutoConfiguration.java b/src/main/java/org/springframework/cloud/gateway/config/GatewayAutoConfiguration.java index 1a7c7fb40..ee60eb0ec 100644 --- a/src/main/java/org/springframework/cloud/gateway/config/GatewayAutoConfiguration.java +++ b/src/main/java/org/springframework/cloud/gateway/config/GatewayAutoConfiguration.java @@ -22,6 +22,7 @@ import org.springframework.cloud.gateway.filter.route.AddRequestParameterRouteFi import org.springframework.cloud.gateway.filter.route.AddResponseHeaderRouteFilter; import org.springframework.cloud.gateway.filter.route.HystrixRouteFilter; import org.springframework.cloud.gateway.filter.route.RedirectToRouteFilter; +import org.springframework.cloud.gateway.filter.route.RemoveNonProxyHeadersRouteFilter; import org.springframework.cloud.gateway.filter.route.RemoveRequestHeaderRouteFilter; import org.springframework.cloud.gateway.filter.route.RemoveResponseHeaderRouteFilter; import org.springframework.cloud.gateway.filter.route.RewritePathRouteFilter; @@ -213,6 +214,11 @@ public class GatewayAutoConfiguration { return new RedirectToRouteFilter(); } + @Bean(name = "RemoveNonProxyHeadersRouteFilter") + public RemoveNonProxyHeadersRouteFilter removeNonProxyHeadersRouteFilter() { + return new RemoveNonProxyHeadersRouteFilter(); + } + @Bean(name = "RemoveRequestHeaderRouteFilter") public RemoveRequestHeaderRouteFilter removeRequestHeaderRouteFilter() { return new RemoveRequestHeaderRouteFilter(); diff --git a/src/main/java/org/springframework/cloud/gateway/filter/route/RemoveNonProxyHeadersRouteFilter.java b/src/main/java/org/springframework/cloud/gateway/filter/route/RemoveNonProxyHeadersRouteFilter.java new file mode 100644 index 000000000..4ac2e3078 --- /dev/null +++ b/src/main/java/org/springframework/cloud/gateway/filter/route/RemoveNonProxyHeadersRouteFilter.java @@ -0,0 +1,64 @@ +package org.springframework.cloud.gateway.filter.route; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.http.server.reactive.ServerHttpRequest; +import org.springframework.web.server.WebFilter; + +import java.util.Arrays; +import java.util.List; + +/** + * Hop-by-hop header fields, which are meaningful only for a single transport-level connection, + * and are not stored by caches or forwarded by proxies. The following HTTP/1.1 header fields + * are hop-by-hop header fields: + *