From cd988384df2f2b0e78b7e247a5beee83508b974c Mon Sep 17 00:00:00 2001 From: Spencer Gibb Date: Mon, 2 Oct 2017 18:21:51 -0400 Subject: [PATCH] Move remove response header to after request is sent. --- .../RemoveResponseHeaderWebFilterFactory.java | 13 +++++++------ .../src/test/resources/application.yml | 11 +++++++---- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/factory/RemoveResponseHeaderWebFilterFactory.java b/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/factory/RemoveResponseHeaderWebFilterFactory.java index 6f7514317..94cd5965e 100644 --- a/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/factory/RemoveResponseHeaderWebFilterFactory.java +++ b/spring-cloud-gateway-core/src/main/java/org/springframework/cloud/gateway/filter/factory/RemoveResponseHeaderWebFilterFactory.java @@ -17,11 +17,13 @@ package org.springframework.cloud.gateway.filter.factory; +import java.util.Arrays; +import java.util.List; + import org.springframework.tuple.Tuple; import org.springframework.web.server.WebFilter; -import java.util.Arrays; -import java.util.List; +import reactor.core.publisher.Mono; /** * @author Spencer Gibb @@ -37,10 +39,9 @@ public class RemoveResponseHeaderWebFilterFactory implements WebFilterFactory { public WebFilter apply(Tuple args) { final String header = args.getString(NAME_KEY); - return (exchange, chain) -> { + return (exchange, chain) -> chain.filter(exchange).then(Mono.defer(() -> { exchange.getResponse().getHeaders().remove(header); - - return chain.filter(exchange); - }; + return Mono.empty(); + })); } } diff --git a/spring-cloud-gateway-core/src/test/resources/application.yml b/spring-cloud-gateway-core/src/test/resources/application.yml index e16ea11f7..dd39f68cd 100644 --- a/spring-cloud-gateway-core/src/test/resources/application.yml +++ b/spring-cloud-gateway-core/src/test/resources/application.yml @@ -184,10 +184,10 @@ spring: args: pattern: /** -#myservice: -# ribbon: -# NIWSServerListClassName: com.netflix.loadbalancer.ConfigurationBasedServerList -# listOfServers: ${test.hostport} +testservice: + ribbon: + NIWSServerListClassName: com.netflix.loadbalancer.ConfigurationBasedServerList + listOfServers: ${test.hostport} hystrix.command.successcmd.execution.isolation.thread.timeoutInMilliseconds: 5000 @@ -200,4 +200,7 @@ logging: management: context-path: /admin +eureka: + client: + enabled: false # port: 8081