From 4cc5ec0b68c6ec20c72cabcf030f13eed5442b9e Mon Sep 17 00:00:00 2001 From: caiqyxyx Date: Wed, 13 May 2020 13:29:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BD=91=E5=85=B3=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E5=BC=82=E5=B8=B8=E4=BF=A1=E6=81=AF=E6=97=B6=E7=9A=84?= =?UTF-8?q?response=20=E8=AF=B7=E6=B1=82=E5=A4=B4=20=E5=9C=A8=E7=BD=91?= =?UTF-8?q?=E5=85=B3=E6=A3=80=E6=9F=A5=E9=AA=8C=E8=AF=81=E7=A0=81=E6=88=96?= =?UTF-8?q?client=E4=BF=A1=E6=81=AF=E4=BA=A7=E7=94=9F=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E5=9C=A8=E8=BF=94=E5=9B=9E=E7=9A=84response?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E5=A4=B4=E4=B8=AD=E6=B7=BB=E5=8A=A0Content-t?= =?UTF-8?q?ype?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pig4cloud/pig/gateway/filter/ValidateCodeGatewayFilter.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/filter/ValidateCodeGatewayFilter.java b/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/filter/ValidateCodeGatewayFilter.java index cf9eae21..b34e106c 100644 --- a/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/filter/ValidateCodeGatewayFilter.java +++ b/pig-gateway/src/main/java/com/pig4cloud/pig/gateway/filter/ValidateCodeGatewayFilter.java @@ -34,6 +34,7 @@ import org.springframework.cloud.gateway.filter.GatewayFilter; import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.http.server.reactive.ServerHttpResponse; import org.springframework.stereotype.Component; @@ -81,6 +82,7 @@ public class ValidateCodeGatewayFilter extends AbstractGatewayFilterFactory { } catch (Exception e) { ServerHttpResponse response = exchange.getResponse(); response.setStatusCode(HttpStatus.PRECONDITION_REQUIRED); + response.getHeaders().setContentType(MediaType.APPLICATION_JSON); try { return response.writeWith(Mono.just(response.bufferFactory() .wrap(objectMapper.writeValueAsBytes(