RFR: 8283544: HttpClient GET method adds Content-Length: 0 header
Conor Cleary
ccleary at openjdk.java.net
Tue Mar 29 16:26:08 UTC 2022
**Issue**
When using the `HttpClient.send()` to send a GET request created using the `HttpRequest.newBuilder()`, a `Content-length: 0` header is set. This behaviour causes issues with many services as a body related header is usually not expected to be included with a GET request.
**Solution**
`Http1Request.java` was modified so that when the request method is a GET, a `Content-length` header is not added to the request. However, if a developer chooses to include a body in a GET request (though it is generally considered bad practice), a `Content-length` header with the appropriate value will be added.
-------------
Commit messages:
- 8283544: HttpClient GET method adds Content-Length: 0 header
Changes: https://git.openjdk.java.net/jdk/pull/8017/files
Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=8017&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8283544
Stats: 168 lines in 2 files changed: 159 ins; 0 del; 9 mod
Patch: https://git.openjdk.java.net/jdk/pull/8017.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/8017/head:pull/8017
PR: https://git.openjdk.java.net/jdk/pull/8017
More information about the net-dev
mailing list