Skip to content

Commit 20baaa6

Browse files
author
Stephane Landelle
committed
0 content-length means empty file, not chunked
1 parent 45cde90 commit 20baaa6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,10 @@ public NettyRequest newNettyRequest(Request request, UriComponents uri, boolean
278278
}
279279

280280
if (body != null) {
281-
if (body.getContentLength() > 0)
282-
httpRequest.headers().set(HttpHeaders.Names.CONTENT_LENGTH, body.getContentLength());
283-
else
281+
if (body.getContentLength() < 0)
284282
httpRequest.headers().set(HttpHeaders.Names.TRANSFER_ENCODING, HttpHeaders.Values.CHUNKED);
283+
else
284+
httpRequest.headers().set(HttpHeaders.Names.CONTENT_LENGTH, body.getContentLength());
285285

286286
if (body.getContentType() != null)
287287
httpRequest.headers().set(HttpHeaders.Names.CONTENT_TYPE, body.getContentType());

0 commit comments

Comments
 (0)