Skip to content

Commit ffe5390

Browse files
committed
minor clean up
1 parent 8848ad6 commit ffe5390

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

src/main/java/com/ning/http/client/providers/netty/request/body/BodyChunkedInput.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,21 @@ public boolean hasNextChunk() throws Exception {
4949
}
5050

5151
public Object nextChunk() throws Exception {
52-
if (endOfInput) {
52+
if (endOfInput)
53+
return null;
54+
55+
ByteBuffer buffer = ByteBuffer.allocate(chunkSize);
56+
long r = body.read(buffer);
57+
if (r < 0L) {
58+
endOfInput = true;
59+
return null;
60+
} else if (r == 0 && body instanceof FeedableBodyGenerator.PushBody) {
61+
//this will suspend the stream in ChunkedWriteHandler
5362
return null;
5463
} else {
55-
ByteBuffer buffer = ByteBuffer.allocate(chunkSize);
56-
long r = body.read(buffer);
57-
if (r < 0L) {
58-
endOfInput = true;
59-
return null;
60-
} else if (r == 0 && body instanceof FeedableBodyGenerator.PushBody) {
61-
//this will suspend the stream in ChunkedWriteHandler
62-
return null;
63-
} else {
64-
endOfInput = r == contentLength || r < chunkSize && contentLength > 0;
65-
buffer.flip();
66-
return ChannelBuffers.wrappedBuffer(buffer);
67-
}
64+
endOfInput = r == contentLength || r < chunkSize && contentLength > 0;
65+
buffer.flip();
66+
return ChannelBuffers.wrappedBuffer(buffer);
6867
}
6968
}
7069

0 commit comments

Comments
 (0)