RFR: 8358942: HttpClient adds Content-Length: 0 for a GET request with a BodyPublishers.noBody() [v2]
Daniel Jeliński
djelinski at openjdk.org
Tue Oct 14 18:00:21 UTC 2025
On Tue, 14 Oct 2025 15:41:12 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:
>> That's not possible in most cases: in HTTP/2 and HTTP/3 we don't send the content-length:0 header, we only send content-length when it's known up front and non-zero.
>> In cases where it is possible it's usually not necessary - most of the time we don't really care if the content length was sent or not, as long as the server is able to figure it out.
>>
>> I'll add a check for the HTTP/1 + PUT/POST case, since that's special-cased by this PR.
>
> If I'm not mistaken in case of H2/H3 you could verify that:
>
>
> assertTrue(List.of("Request completed, no content length", "Request completed").contains(resp.body()), "Unexpected response: " + resp.body());
I ended up removing the `OptionalContentLengthHandler`. It didn't feel right anyway.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27727#discussion_r2430005728
More information about the net-dev
mailing list