On Wed, 26 Feb 2025 11:19:08 GMT, Volkan Yazici <vyaz...@openjdk.org> wrote:
>> Hi - Please find here a PR that improves streaming strategy in the >> HttpClient. >> >> The HttpClient currently waits until the full request body has been sent >> before starting to listen for a response. This is not optimal, in particular >> in cases where the server sends back e.g. 500 without even reading the body. >> It also prevents starting to stream the response body from the server before >> having sent the full request body, which prevents the server to stream back >> the request body to the client without reading it fully first. >> >> While writing a test to verify the fix, I also noticed a few places where >> additional tasks needed to be performed asynchronously (= delegated to the >> executor) to support this. > > src/java.net.http/share/classes/jdk/internal/net/http/Exchange.java line 428: > >> 426: var sendBody = exchImpl.sendBodyAsync(); >> 427: CompletableFuture<Response> cf = >> exchImpl.getResponseAsync(executor); >> 428: sendBody.exceptionally((t) -> { > > Shouldn't this be `sendBody = sendBody.exceptionally(...)`? No - because if sendBody is completed exceptionally we want the dependent action to be executed. So `sendBody` should be the head, not the tail. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/23716#discussion_r1971423491