RFR: 8283544: HttpClient GET method adds Content-Length: 0 header [v8]

Jaikiran Pai jpai at openjdk.java.net
Mon May 16 13:14:16 UTC 2022


On Mon, 16 May 2022 08:59:43 GMT, Conor Cleary <ccleary at openjdk.org> wrote:

>> **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.
>
> Conor Cleary has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8283544: Added in missing case

Thank you for the changes, Conor. The latest state looks fine to me.

-------------

Marked as reviewed by jpai (Committer).

PR: https://git.openjdk.java.net/jdk/pull/8017


More information about the net-dev mailing list