Skip to content

Commit 036bc73

Browse files
author
Stephane Landelle
committed
FeedableBodyGenerator shouldn't output 2 last empty lines, close #781
1 parent ee38f65 commit 036bc73

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

providers/netty3/src/main/java/org/asynchttpclient/providers/netty3/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;

providers/netty4/src/main/java/org/asynchttpclient/providers/netty4/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)