On Tue, 14 Oct 2025 15:00:38 GMT, Daniel Jeliński <[email protected]> wrote:

>> test/jdk/java/net/httpclient/ContentLengthHeaderTest.java line 217:
>> 
>>> 215:         assertEquals(resp.statusCode(), 200, resp.body());
>>> 216:         assertEquals(resp.version(), version);
>>> 217:         assertEquals(resp.body(), "Request completed");
>> 
>> If possible, you may consider verifying the response body in other test 
>> methods too, since, in particular, `OptionalContentLengthHandler` responds 
>> with 200 in two different scenarios.
>
> 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());

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27727#discussion_r2429642984

Reply via email to