flink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject flink git commit: [FLINK-5109] [webfrontend] Fix invalid content-encoding
Date Sat, 03 Dec 2016 17:19:09 GMT
Repository: flink
Updated Branches:
  refs/heads/master e4f802dd5 -> 08e7ba492


[FLINK-5109] [webfrontend] Fix invalid content-encoding

This closes #2898


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/08e7ba49
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/08e7ba49
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/08e7ba49

Branch: refs/heads/master
Commit: 08e7ba4920b9b44dc15269e4f507d89025209937
Parents: e4f802d
Author: tibor.moger <tibor.moger@smartx.eu>
Authored: Mon Nov 28 16:51:47 2016 +0100
Committer: Greg Hogan <code@greghogan.com>
Committed: Sat Dec 3 12:07:53 2016 -0500

----------------------------------------------------------------------
 .../runtime/webmonitor/HttpRequestHandler.java  | 37 ++++++++++----------
 .../webmonitor/PipelineErrorHandler.java        |  1 -
 .../webmonitor/RuntimeMonitorHandler.java       |  4 +--
 .../handlers/ConstantTextHandler.java           |  9 +++--
 .../handlers/HandlerRedirectUtils.java          |  2 --
 5 files changed, 23 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/08e7ba49/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/HttpRequestHandler.java
----------------------------------------------------------------------
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 bbd29fa..703b621 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
@@ -66,7 +66,7 @@ import java.util.UUID;
 public class HttpRequestHandler extends SimpleChannelInboundHandler<HttpObject> {
 
 	private static final Charset ENCODING = Charset.forName("UTF-8");
-	
+
 	/** A decoder factory that always stores POST chunks on disk */
 	private static final HttpDataFactory DATA_FACTORY = new DefaultHttpDataFactory(true);
 
@@ -80,7 +80,7 @@ public class HttpRequestHandler extends SimpleChannelInboundHandler<HttpObject>
 	public HttpRequestHandler(File tmpDir) {
 		this.tmpDir = tmpDir;
 	}
-	
+
 	@Override
 	public void channelUnregistered(ChannelHandlerContext ctx) throws Exception {
 		if (currentDecoder != null) {
@@ -94,12 +94,12 @@ public class HttpRequestHandler extends SimpleChannelInboundHandler<HttpObject>
 			if (msg instanceof HttpRequest) {
 				currentRequest = (HttpRequest) msg;
 				currentRequestPath = null;
-				
+
 				if (currentDecoder != null) {
 					currentDecoder.destroy();
 					currentDecoder = null;
 				}
-				
+
 				if (currentRequest.getMethod() == HttpMethod.GET || currentRequest.getMethod() == HttpMethod.DELETE)
{
 					// directly delegate to the router
 					ctx.fireChannelRead(currentRequest);
@@ -118,43 +118,43 @@ public class HttpRequestHandler extends SimpleChannelInboundHandler<HttpObject>
 				// received new chunk, give it to the current decoder
 				HttpContent chunk = (HttpContent) msg;
 				currentDecoder.offer(chunk);
-				
+
 				try {
 					while (currentDecoder.hasNext()) {
 						InterfaceHttpData data = currentDecoder.next();
-						
+
 						// IF SOMETHING EVER NEEDS POST PARAMETERS, THIS WILL BE THE PLACE TO HANDLE IT
 						// all fields values will be passed with type Attribute.
-						
+
 						if (data.getHttpDataType() == HttpDataType.FileUpload) {
 							DiskFileUpload file = (DiskFileUpload) data;
 							if (file.isCompleted()) {
 								String name = file.getFilename();
-								
+
 								File target = new File(tmpDir, UUID.randomUUID() + "_" + name);
 								file.renameTo(target);
-								
+
 								QueryStringEncoder encoder = new QueryStringEncoder(currentRequestPath);
 								encoder.addParam("filepath", target.getAbsolutePath());
 								encoder.addParam("filename", name);
-								
+
 								currentRequest.setUri(encoder.toString());
 							}
 						}
-						
+
 						data.release();
 					}
 				}
 				catch (EndOfDataDecoderException ignored) {}
-				
+
 				if (chunk instanceof LastHttpContent) {
 					HttpRequest request = currentRequest;
 					currentRequest = null;
 					currentRequestPath = null;
-					
+
 					currentDecoder.destroy();
 					currentDecoder = null;
-					
+
 					// fire next channel handler
 					ctx.fireChannelRead(request);
 				}
@@ -163,20 +163,19 @@ public class HttpRequestHandler extends SimpleChannelInboundHandler<HttpObject>
 		catch (Throwable t) {
 			currentRequest = null;
 			currentRequestPath = null;
-			
+
 			if (currentDecoder != null) {
 				currentDecoder.destroy();
 				currentDecoder = null;
 			}
-			
+
 			if (ctx.channel().isActive()) {
 				byte[] bytes = ExceptionUtils.stringifyException(t).getBytes(ENCODING);
-				
+
 				DefaultFullHttpResponse response = new DefaultFullHttpResponse(
 					HttpVersion.HTTP_1_1, HttpResponseStatus.INTERNAL_SERVER_ERROR,
 					Unpooled.wrappedBuffer(bytes));
-	
-				response.headers().set(HttpHeaders.Names.CONTENT_ENCODING, "utf-8");
+
 				response.headers().set(HttpHeaders.Names.CONTENT_TYPE, "text/plain");
 				response.headers().set(HttpHeaders.Names.CONTENT_LENGTH, response.content().readableBytes());
 

http://git-wip-us.apache.org/repos/asf/flink/blob/08e7ba49/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/PipelineErrorHandler.java
----------------------------------------------------------------------
diff --git a/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/PipelineErrorHandler.java
b/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/PipelineErrorHandler.java
index 23a0ba6..b4788dd 100644
--- a/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/PipelineErrorHandler.java
+++ b/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/PipelineErrorHandler.java
@@ -64,7 +64,6 @@ public class PipelineErrorHandler extends SimpleChannelInboundHandler<Object>
{
 						HttpResponseStatus.INTERNAL_SERVER_ERROR, Unpooled.wrappedBuffer(error.getBytes()));
 
 			response.headers().set(HttpHeaders.Names.CONTENT_TYPE, "text/plain");
-			response.headers().set(HttpHeaders.Names.CONTENT_ENCODING, "utf-8");
 			response.headers().set(HttpHeaders.Names.CONTENT_LENGTH, response.content().readableBytes());
 
 			ctx.writeAndFlush(response);

http://git-wip-us.apache.org/repos/asf/flink/blob/08e7ba49/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/RuntimeMonitorHandler.java
----------------------------------------------------------------------
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 aba4e17..68e1735 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
@@ -61,7 +61,7 @@ public class RuntimeMonitorHandler extends RuntimeMonitorHandlerBase {
 	private static final Charset ENCODING = Charset.forName("UTF-8");
 
 	public static final String WEB_MONITOR_ADDRESS_KEY = "web.monitor.address";
-	
+
 	private final RequestHandler handler;
 
 	public RuntimeMonitorHandler(
@@ -102,7 +102,6 @@ public class RuntimeMonitorHandler extends RuntimeMonitorHandlerBase {
 					: Unpooled.wrappedBuffer(e.getMessage().getBytes(ENCODING));
 			response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.NOT_FOUND,
message);
 			response.headers().set(HttpHeaders.Names.CONTENT_TYPE, "text/plain");
-			response.headers().set(HttpHeaders.Names.CONTENT_ENCODING, "utf-8");
 			response.headers().set(HttpHeaders.Names.CONTENT_LENGTH, response.content().readableBytes());
 			LOG.debug("Error while handling request", e);
 		}
@@ -111,7 +110,6 @@ public class RuntimeMonitorHandler extends RuntimeMonitorHandlerBase {
 			response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1,
 					HttpResponseStatus.INTERNAL_SERVER_ERROR, Unpooled.wrappedBuffer(bytes));
 			response.headers().set(HttpHeaders.Names.CONTENT_TYPE, "text/plain");
-			response.headers().set(HttpHeaders.Names.CONTENT_ENCODING, "utf-8");
 			response.headers().set(HttpHeaders.Names.CONTENT_LENGTH, response.content().readableBytes());
 
 			LOG.debug("Error while handling request", e);

http://git-wip-us.apache.org/repos/asf/flink/blob/08e7ba49/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/handlers/ConstantTextHandler.java
----------------------------------------------------------------------
diff --git a/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/handlers/ConstantTextHandler.java
b/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/handlers/ConstantTextHandler.java
index aedf0c2..127efdb 100644
--- a/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/handlers/ConstantTextHandler.java
+++ b/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/handlers/ConstantTextHandler.java
@@ -37,9 +37,9 @@ import java.io.UnsupportedEncodingException;
  */
 @ChannelHandler.Sharable
 public class ConstantTextHandler extends SimpleChannelInboundHandler<Routed> {
-	
+
 	private final byte[] encodedText;
-	
+
 	public ConstantTextHandler(String text) {
 		try {
 			this.encodedText = text.getBytes("UTF-8");
@@ -48,16 +48,15 @@ public class ConstantTextHandler extends SimpleChannelInboundHandler<Routed>
{
 			throw new RuntimeException(e.getMessage(), e);
 		}
 	}
-	
+
 	@Override
 	protected void channelRead0(ChannelHandlerContext ctx, Routed routed) throws Exception {
 		HttpResponse response = new DefaultFullHttpResponse(
 			HttpVersion.HTTP_1_1, HttpResponseStatus.OK, Unpooled.wrappedBuffer(encodedText));
 
 		response.headers().set(HttpHeaders.Names.CONTENT_LENGTH, encodedText.length);
-		response.headers().set(HttpHeaders.Names.CONTENT_ENCODING, "utf-8");
 		response.headers().set(HttpHeaders.Names.CONTENT_TYPE, "text/plain");
-		
+
 		KeepAliveWrite.flush(ctx, routed.request(), response);
 	}
 }

http://git-wip-us.apache.org/repos/asf/flink/blob/08e7ba49/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/handlers/HandlerRedirectUtils.java
----------------------------------------------------------------------
diff --git a/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/handlers/HandlerRedirectUtils.java
b/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/handlers/HandlerRedirectUtils.java
index 21a0f8c..ca61ec1 100644
--- a/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/handlers/HandlerRedirectUtils.java
+++ b/flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/handlers/HandlerRedirectUtils.java
@@ -89,7 +89,6 @@ public class HandlerRedirectUtils {
 		HttpResponse redirectResponse = new DefaultFullHttpResponse(
 				HttpVersion.HTTP_1_1, HttpResponseStatus.TEMPORARY_REDIRECT);
 		redirectResponse.headers().set(HttpHeaders.Names.LOCATION, newLocation);
-		redirectResponse.headers().set(HttpHeaders.Names.CONTENT_ENCODING, "utf-8");
 		redirectResponse.headers().set(HttpHeaders.Names.CONTENT_LENGTH, 0);
 
 		return redirectResponse;
@@ -102,7 +101,6 @@ public class HandlerRedirectUtils {
 		HttpResponse unavailableResponse = new DefaultFullHttpResponse(
 				HttpVersion.HTTP_1_1, HttpResponseStatus.SERVICE_UNAVAILABLE, Unpooled.wrappedBuffer(bytes));
 
-		unavailableResponse.headers().set(HttpHeaders.Names.CONTENT_ENCODING, "utf-8");
 		unavailableResponse.headers().set(HttpHeaders.Names.CONTENT_LENGTH, bytes.length);
 		unavailableResponse.headers().set(HttpHeaders.Names.CONTENT_TYPE, MimeTypes.getMimeTypeForExtension("txt"));
 


Mime
View raw message