diff --git a/src/main/java/org/jboss/netty/handler/stream/ChunkedStream.java b/src/main/java/org/jboss/netty/handler/stream/ChunkedStream.java index 6d566a6960..0857167efd 100644 --- a/src/main/java/org/jboss/netty/handler/stream/ChunkedStream.java +++ b/src/main/java/org/jboss/netty/handler/stream/ChunkedStream.java @@ -93,7 +93,13 @@ public class ChunkedStream implements ChunkedInput { return null; } - final int chunkSize = Math.min(this.chunkSize, in.available()); + final int availableBytes = in.available(); + final int chunkSize; + if (availableBytes <= 0) { + chunkSize = this.chunkSize; + } else { + chunkSize = Math.min(this.chunkSize, in.available()); + } final byte[] chunk = new byte[chunkSize]; int readBytes = 0; for (;;) {