From adff62fe0c750044c265111b3b5b9472ab60cb08 Mon Sep 17 00:00:00 2001 From: shijinkui Date: Fri, 3 Feb 2017 17:26:18 +0800 Subject: [PATCH] [FLINK-5705] [WebMonitor] webmonitor request/response use UTF-8 explicitly --- .../apache/flink/runtime/webmonitor/HttpRequestHandler.java | 4 ++-- .../flink/runtime/webmonitor/RuntimeMonitorHandler.java | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/HttpRequestHandler.java b/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/HttpRequestHandler.java index 703b621bfd062..585a2f3c64d3d 100644 --- a/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/HttpRequestHandler.java +++ b/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/HttpRequestHandler.java @@ -107,8 +107,8 @@ public void channelRead0(ChannelHandlerContext ctx, HttpObject msg) { else if (currentRequest.getMethod() == HttpMethod.POST) { // POST comes in multiple objects. First the request, then the contents // keep the request and path for the remaining objects of the POST request - currentRequestPath = new QueryStringDecoder(currentRequest.getUri()).path(); - currentDecoder = new HttpPostRequestDecoder(DATA_FACTORY, currentRequest); + currentRequestPath = new QueryStringDecoder(currentRequest.getUri(), ENCODING).path(); + currentDecoder = new HttpPostRequestDecoder(DATA_FACTORY, currentRequest, ENCODING); } else { throw new IOException("Unsupported HTTP method: " + currentRequest.getMethod().name()); diff --git a/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/RuntimeMonitorHandler.java b/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/RuntimeMonitorHandler.java index 68e17351b21b6..40373fa77e88d 100644 --- a/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/RuntimeMonitorHandler.java +++ b/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/RuntimeMonitorHandler.java @@ -32,6 +32,7 @@ import java.net.URLDecoder; import org.apache.flink.runtime.instance.ActorGateway; +import org.apache.flink.runtime.webmonitor.files.MimeTypes; import org.apache.flink.runtime.webmonitor.handlers.RequestHandler; import org.apache.flink.util.ExceptionUtils; @@ -116,6 +117,8 @@ protected void respondAsLeader(ChannelHandlerContext ctx, Routed routed, ActorGa } response.headers().set(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_ORIGIN, "*"); + // Content-Encoding:utf-8 + response.headers().set(HttpHeaders.Names.CONTENT_ENCODING, ENCODING.name()); KeepAliveWrite.flush(ctx, routed.request(), response); }