Skip to content

Commit

Permalink
Upgraded netty
Browse files Browse the repository at this point in the history
  • Loading branch information
pepite committed May 16, 2010
1 parent 58ef831 commit 7ec8b64
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Binary file removed lib/netty-3.1.5.GA.jar
Binary file not shown.
Binary file added lib/netty-3.2.0.CR1.jar
Binary file not shown.
18 changes: 9 additions & 9 deletions src/play/modules/netty/PlayHandler.java
Expand Up @@ -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 { protected static void writeResponse(ChannelHandlerContext ctx, Response response, HttpResponse nettyResponse, HttpRequest nettyRequest) throws IOException {
byte[] content = null; byte[] content = null;


final boolean keepAlive = isKeepAlive(nettyResponse); final boolean keepAlive = isKeepAlive(nettyRequest);
if (nettyRequest.getMethod().equals(HttpMethod.HEAD)) { if (nettyRequest.getMethod().equals(HttpMethod.HEAD)) {
content = new byte[0]; content = new byte[0];
} else { } else {
Expand All @@ -228,9 +228,9 @@ protected static void writeResponse(ChannelHandlerContext ctx, Response response


ChannelBuffer buf = ChannelBuffers.copiedBuffer(content); ChannelBuffer buf = ChannelBuffers.copiedBuffer(content);
nettyResponse.setContent(buf); nettyResponse.setContent(buf);
//if (keepAlive) { if (keepAlive) {
setContentLength(nettyResponse, response.out.size()); setContentLength(nettyResponse, response.out.size());
//} }
ChannelFuture f = ctx.getChannel().write(nettyResponse); ChannelFuture f = ctx.getChannel().write(nettyResponse);


// Decide whether to close the connection or not. // Decide whether to close the connection or not.
Expand Down Expand Up @@ -266,7 +266,7 @@ public static void copyResponse(ChannelHandlerContext ctx, Request request, Resp
is = (InputStream) obj; is = (InputStream) obj;
} }


final boolean keepAlive = isKeepAlive(nettyResponse); final boolean keepAlive = isKeepAlive(nettyRequest);
if (file != null && file.isFile()) { if (file != null && file.isFile()) {
try { try {


Expand Down Expand Up @@ -595,9 +595,9 @@ public static void serveStatic(RenderStatic renderStatic, ChannelHandlerContext
Logger.trace("keep alive " + keepAlive); Logger.trace("keep alive " + keepAlive);
Logger.trace("content type " + (MimeTypes.getContentType(localFile.getName(), "text/plain"))); Logger.trace("content type " + (MimeTypes.getContentType(localFile.getName(), "text/plain")));


//if (isKeepAlive(nettyRequest)) { if (keepAlive) {
setContentLength(nettyResponse, fileLength); setContentLength(nettyResponse, fileLength);
//} }
nettyResponse.setHeader(CONTENT_TYPE, (MimeTypes.getContentType(localFile.getName(), "text/plain"))); nettyResponse.setHeader(CONTENT_TYPE, (MimeTypes.getContentType(localFile.getName(), "text/plain")));


Channel ch = e.getChannel(); Channel ch = e.getChannel();
Expand All @@ -608,7 +608,7 @@ public static void serveStatic(RenderStatic renderStatic, ChannelHandlerContext
// Write the content. // Write the content.
ChannelFuture writeFuture = ch.write(new ChunkedFile(raf, 0, fileLength, 8192)); 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. // Close the connection when the whole content is written out.
writeFuture.addListener(ChannelFutureListener.CLOSE); writeFuture.addListener(ChannelFutureListener.CLOSE);
} }
Expand Down

0 comments on commit 7ec8b64

Please sign in to comment.