Skip to content

Commit ec1f32f

Browse files
committed
Use BodyChunkedInput in contentLength < 0 in NettyBodyBody
1 parent 7f5c687 commit ec1f32f

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

client/src/main/java/org/asynchttpclient/netty/request/body/NettyBodyBody.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,8 @@ public long getContentLength() {
5353
public void write(final Channel channel, NettyResponseFuture<?> future) {
5454

5555
Object msg;
56-
if (body instanceof RandomAccessBody && !ChannelManager.isSslHandlerConfigured(channel.pipeline()) && !config.isDisableZeroCopy()) {
57-
long contentLength = getContentLength();
58-
if (contentLength < 0) {
59-
// contentLength unknown in advance, use chunked input
60-
msg = new BodyChunkedInput(body);
61-
} else {
62-
msg = new BodyFileRegion((RandomAccessBody) body);
63-
}
56+
if (body instanceof RandomAccessBody && !ChannelManager.isSslHandlerConfigured(channel.pipeline()) && !config.isDisableZeroCopy() && getContentLength() > 0) {
57+
msg = new BodyFileRegion((RandomAccessBody) body);
6458

6559
} else {
6660
msg = new BodyChunkedInput(body);

0 commit comments

Comments
 (0)