Skip to content

Commit

Permalink
[FLINK-5705] [WebMonitor] WebMonitor request/response use UTF-8 expli…
Browse files Browse the repository at this point in the history
…citly

This closes apache#3257
  • Loading branch information
shijinkui authored and StephanEwen committed Feb 16, 2017
1 parent 494edb0 commit f245143
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,18 @@
import io.netty.handler.codec.http.router.KeepAliveWrite;
import io.netty.handler.codec.http.router.Routed;

import java.net.URLDecoder;
import org.apache.flink.runtime.instance.ActorGateway;
import org.apache.flink.runtime.webmonitor.handlers.RequestHandler;
import org.apache.flink.util.ExceptionUtils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import scala.concurrent.Future;
import scala.concurrent.duration.FiniteDuration;

import java.net.InetSocketAddress;
import java.net.URLDecoder;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit f245143

Please sign in to comment.