Skip to content

Commit a8b89b4

Browse files
author
Stephane Landelle
committed
FeedableBodyGenerator shouldn't output 2 last empty lines, close AsyncHttpClient#781
1 parent 4815909 commit a8b89b4

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,14 @@ public long read(final ByteBuffer buffer) throws IOException {
8888
}
8989
int capacity = buffer.remaining() - 10; // be safe (we'll have to add size, ending, etc.)
9090
int size = Math.min(nextPart.buffer.remaining(), capacity);
91-
buffer.put(Integer.toHexString(size).getBytes(US_ASCII));
92-
buffer.put(END_PADDING);
93-
for (int i = 0; i < size; i++) {
94-
buffer.put(nextPart.buffer.get());
91+
if (size != 0) {
92+
buffer.put(Integer.toHexString(size).getBytes(US_ASCII));
93+
buffer.put(END_PADDING);
94+
for (int i = 0; i < size; i++) {
95+
buffer.put(nextPart.buffer.get());
96+
}
97+
buffer.put(END_PADDING);
9598
}
96-
buffer.put(END_PADDING);
9799
if (!nextPart.buffer.hasRemaining()) {
98100
if (nextPart.isLast) {
99101
finishState = CLOSING;

0 commit comments

Comments
 (0)