diff --git a/lib/netty-3.1.5.GA.jar b/lib/netty-3.1.5.GA.jar deleted file mode 100644 index 18f2845..0000000 Binary files a/lib/netty-3.1.5.GA.jar and /dev/null differ diff --git a/lib/netty-3.2.0.CR1.jar b/lib/netty-3.2.0.CR1.jar new file mode 100644 index 0000000..29d3ea4 Binary files /dev/null and b/lib/netty-3.2.0.CR1.jar differ diff --git a/src/play/modules/netty/PlayHandler.java b/src/play/modules/netty/PlayHandler.java index cf08b6e..9967b00 100644 --- a/src/play/modules/netty/PlayHandler.java +++ b/src/play/modules/netty/PlayHandler.java @@ -219,7 +219,7 @@ protected static void addToResponse(Response response, HttpResponse nettyRespons protected static void writeResponse(ChannelHandlerContext ctx, Response response, HttpResponse nettyResponse, HttpRequest nettyRequest) throws IOException { byte[] content = null; - final boolean keepAlive = isKeepAlive(nettyResponse); + final boolean keepAlive = isKeepAlive(nettyRequest); if (nettyRequest.getMethod().equals(HttpMethod.HEAD)) { content = new byte[0]; } else { @@ -228,9 +228,9 @@ protected static void writeResponse(ChannelHandlerContext ctx, Response response ChannelBuffer buf = ChannelBuffers.copiedBuffer(content); nettyResponse.setContent(buf); - //if (keepAlive) { - setContentLength(nettyResponse, response.out.size()); - //} + if (keepAlive) { + setContentLength(nettyResponse, response.out.size()); + } ChannelFuture f = ctx.getChannel().write(nettyResponse); // Decide whether to close the connection or not. @@ -266,7 +266,7 @@ public static void copyResponse(ChannelHandlerContext ctx, Request request, Resp is = (InputStream) obj; } - final boolean keepAlive = isKeepAlive(nettyResponse); + final boolean keepAlive = isKeepAlive(nettyRequest); if (file != null && file.isFile()) { try { @@ -595,9 +595,9 @@ public static void serveStatic(RenderStatic renderStatic, ChannelHandlerContext Logger.trace("keep alive " + keepAlive); Logger.trace("content type " + (MimeTypes.getContentType(localFile.getName(), "text/plain"))); - //if (isKeepAlive(nettyRequest)) { - setContentLength(nettyResponse, fileLength); - //} + if (keepAlive) { + setContentLength(nettyResponse, fileLength); + } nettyResponse.setHeader(CONTENT_TYPE, (MimeTypes.getContentType(localFile.getName(), "text/plain"))); Channel ch = e.getChannel(); @@ -608,7 +608,7 @@ public static void serveStatic(RenderStatic renderStatic, ChannelHandlerContext // Write the content. ChannelFuture writeFuture = ch.write(new ChunkedFile(raf, 0, fileLength, 8192)); - if (!isKeepAlive(nettyRequest)) { + if (!keepAlive) { // Close the connection when the whole content is written out. writeFuture.addListener(ChannelFutureListener.CLOSE); }