Skip to content

Commit 5244db4

Browse files
author
Dave Syer
committed
Apache HTTP client hates to have the Content-Length set
It always sets the header itself and if we set it as well it barfs so it is better just to avoid setting it at all.
1 parent 715e72b commit 5244db4

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

httpclient/src/main/java/feign/httpclient/ApacheHttpClient.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,9 @@ HttpUriRequest toHttpUriRequest(Request request, Request.Options options) throws
118118
hasAcceptHeader = true;
119119
}
120120

121-
if (headerName.equalsIgnoreCase(Util.CONTENT_LENGTH) &&
122-
requestBuilder.getHeaders(headerName) != null) {
123-
//if the 'Content-Length' header is already present, it's been set from HttpEntity, so we
124-
//won't add it again
121+
if (headerName.equalsIgnoreCase(Util.CONTENT_LENGTH)) {
122+
// The 'Content-Length' header is always set by the Apache client and it
123+
// doesn't like us to set it as well.
125124
continue;
126125
}
127126

0 commit comments

Comments
 (0)