Fix the bug that Chinese characters are malformed in response body of ZuulBlockFallbackProvider (#737)

This commit is contained in:
尹吉欢 2019-05-09 10:07:27 +08:00 committed by Eric Zhao
parent 6e4560845c
commit 274ecb51c3
2 changed files with 3 additions and 1 deletions

View File

@ -133,6 +133,8 @@ public class SentinelZuulPreFilter extends ZuulFilter {
// Set fallback response.
ctx.setResponseBody(blockResponse.toString());
ctx.setResponseStatusCode(blockResponse.getCode());
// Set Response ContentType
ctx.getResponse().setContentType("application/json; charset=utf-8");
} finally {
// We don't exit the entry here. We need to exit the entries in post filter to record Rt correctly.
// So here the entries will be carried in the request context.

View File

@ -43,4 +43,4 @@ public class ZuulConfig {
public ZuulFilter sentinelZuulErrorFilter() {
return new SentinelZuulErrorFilter(-1);
}
}
}