-
Bug
-
Resolution: Fixed
-
P4
-
11, 17, 18, 19
-
b23
-
generic
-
generic
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8369287 | 17.0.18-oracle | Sean Coffey | P4 | Resolved | Fixed | b01 |
A DESCRIPTION OF THE PROBLEM :
Using HttpRequest.newBuilder() to create a simple GET() request, and executing it using HttpClient's send() method sends an HTTP 1.1 header containing the content-length: 0 header+value.
Quite some services die on this header because they do not expect a body related header for a get.
The code in question is in Http1Request method headers() which contains:
if (contentLength == 0) {
systemHeadersBuilder.setHeader("Content-Length", "0");
} else if (contentLength > 0) {
systemHeadersBuilder.setHeader("Content-Length", Long.toString(contentLength));
streaming = false;
} else {
streaming = true;
systemHeadersBuilder.setHeader("Transfer-encoding", "chunked");
}
This always sends a body related header. It should probably skip this part altogether for a GET.
FREQUENCY : always
Using HttpRequest.newBuilder() to create a simple GET() request, and executing it using HttpClient's send() method sends an HTTP 1.1 header containing the content-length: 0 header+value.
Quite some services die on this header because they do not expect a body related header for a get.
The code in question is in Http1Request method headers() which contains:
if (contentLength == 0) {
systemHeadersBuilder.setHeader("Content-Length", "0");
} else if (contentLength > 0) {
systemHeadersBuilder.setHeader("Content-Length", Long.toString(contentLength));
streaming = false;
} else {
streaming = true;
systemHeadersBuilder.setHeader("Transfer-encoding", "chunked");
}
This always sends a body related header. It should probably skip this part altogether for a GET.
FREQUENCY : always
- backported by
-
JDK-8369287 HttpClient GET method adds Content-Length: 0 header
-
- Resolved
-
- duplicates
-
JDK-8283605 HttpClient adding Content-Length: 0 to GET requests
-
- Closed
-
- relates to
-
JDK-8358942 HttpClient adds Content-Length: 0 for a GET request with a BodyPublishers.noBody()
-
- Open
-