Skip to content
Browse files

Upgraded netty

  • Loading branch information...
1 parent 58ef831 commit 7ec8b6466f7a806dee34698780a322302e6648d8 @pepite pepite committed May 16, 2010
View
BIN lib/netty-3.1.5.GA.jar
Binary file not shown.
View
BIN lib/netty-3.2.0.CR1.jar
Binary file not shown.
View
18 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);
}

0 comments on commit 7ec8b64

Please sign in to comment.
Something went wrong with that request. Please try again.