diff --git a/src/main/java/org/jboss/netty/example/http/file/HttpStaticFileServerHandler.java b/src/main/java/org/jboss/netty/example/http/file/HttpStaticFileServerHandler.java index 632d06115d..840d3c7ea6 100644 --- a/src/main/java/org/jboss/netty/example/http/file/HttpStaticFileServerHandler.java +++ b/src/main/java/org/jboss/netty/example/http/file/HttpStaticFileServerHandler.java @@ -56,11 +56,6 @@ public class HttpStaticFileServerHandler extends SimpleChannelUpstreamHandler { return; } - if (request.isChunked()) { - sendError(ctx, HttpResponseStatus.BAD_REQUEST); - return; - } - String path = sanitizeUri(request.getUri()); if (path == null) { sendError(ctx, HttpResponseStatus.FORBIDDEN); @@ -100,11 +95,7 @@ public class HttpStaticFileServerHandler extends SimpleChannelUpstreamHandler { ChannelFuture writeFuture = ch.write(new ChunkedFile(raf, 0, fileLength, 8192)); // Decide whether to close the connection or not. - boolean close = - HttpHeaders.Values.CLOSE.equalsIgnoreCase(request.getHeader(HttpHeaders.Names.CONNECTION)) || - request.getProtocolVersion().equals(HttpVersion.HTTP_1_0) && - !HttpHeaders.Values.KEEP_ALIVE.equalsIgnoreCase(request.getHeader(HttpHeaders.Names.CONNECTION)); - + boolean close = !request.isKeepAlive(); if (close) { // Close the connection when the whole content is written out. writeFuture.addListener(ChannelFutureListener.CLOSE); diff --git a/src/main/java/org/jboss/netty/example/http/file/HttpStaticFileServerPipelineFactory.java b/src/main/java/org/jboss/netty/example/http/file/HttpStaticFileServerPipelineFactory.java index 289f0c22f2..f7733949d4 100644 --- a/src/main/java/org/jboss/netty/example/http/file/HttpStaticFileServerPipelineFactory.java +++ b/src/main/java/org/jboss/netty/example/http/file/HttpStaticFileServerPipelineFactory.java @@ -19,6 +19,7 @@ import static org.jboss.netty.channel.Channels.*; import org.jboss.netty.channel.ChannelPipeline; import org.jboss.netty.channel.ChannelPipelineFactory; +import org.jboss.netty.handler.codec.http.HttpChunkAggregator; import org.jboss.netty.handler.codec.http.HttpRequestDecoder; import org.jboss.netty.handler.codec.http.HttpResponseEncoder; import org.jboss.netty.handler.stream.ChunkedWriteHandler; @@ -38,6 +39,7 @@ public class HttpStaticFileServerPipelineFactory implements ChannelPipelineFacto //pipeline.addLast("ssl", new SslHandler(engine)); pipeline.addLast("decoder", new HttpRequestDecoder()); + pipeline.addLast("aggregator", new HttpChunkAggregator(65536)); pipeline.addLast("encoder", new HttpResponseEncoder()); pipeline.addLast("chunkedWriter", new ChunkedWriteHandler());