Integrated: 8308024: HttpClient (HTTP/1.1) sends an extraneous empty chunk if the BodyPublisher supplies an empty buffer

Daniel Fuchs dfuchs at openjdk.org
Tue May 16 09:17:01 UTC 2023


On Mon, 15 May 2023 14:21:57 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:

> When using HTTP/1.1, if a BodyPublisher reports an unknown length (-1), the HttpClient will send the request body in Chunked mode. If the publisher publishes an empty byte buffer, the client will generate an empty chunk, which the server will interpret as the end of the request body. Sending an empty chunk can never be valid, unless it's the last body chunk and marks the end of the body.
> 
> A new subclass of `AbstractNoBody.java` `NoBodyPartThree.java` is created to check this scenario. While at it, the tests `java/net/httpclient/NoBodyPartOne.java` and `java/net/httpclient/NoBodyPartTwo.java` which create a lot of clients are also updated to make use of `HttpClient::close`.

This pull request has now been integrated.

Changeset: 72294c54
Author:    Daniel Fuchs <dfuchs at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/72294c5402dd11e3eb4922ad26e1b153098495ff
Stats:     454 lines in 5 files changed: 283 ins; 37 del; 134 mod

8308024: HttpClient (HTTP/1.1) sends an extraneous empty chunk if the BodyPublisher supplies an empty buffer

Reviewed-by: djelinski, michaelm

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

PR: https://git.openjdk.org/jdk/pull/13988


More information about the net-dev mailing list