Skip to content

Commit

Permalink
User defined Content-Length request header should be honored, close #…
Browse files Browse the repository at this point in the history
…1440

Motivation:

When Content-Length is known beforehand, we shouldn’t ignore it and
enforce chunked transfer-encoding.

Modification:

Honor Content-Length request header when it's defined.

Result:

Chunked transfer-encoding is no longer enforced
  • Loading branch information
slandelle committed Jul 25, 2017
1 parent e0b097d commit 1d8a630
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,12 @@ public NettyRequest newNettyRequest(Request request, boolean forceConnect, Proxy
}

if (body != null) {
if (body.getContentLength() < 0) {
headers.set(TRANSFER_ENCODING, HttpHeaderValues.CHUNKED);
} else {
headers.set(CONTENT_LENGTH, body.getContentLength());
if (!headers.contains(CONTENT_LENGTH)) {
if (body.getContentLength() < 0) {
headers.set(TRANSFER_ENCODING, HttpHeaderValues.CHUNKED);
} else {
headers.set(CONTENT_LENGTH, body.getContentLength());
}
}

if (body.getContentTypeOverride() != null) {
Expand Down

0 comments on commit 1d8a630

Please sign in to comment.