RFR: 8286171: HttpClient/2 : Expect:100-Continue blocks indefinitely when response is not 100 [v2]
Daniel Fuchs
dfuchs at openjdk.java.net
Thu Jun 9 11:29:40 UTC 2022
On Thu, 9 Jun 2022 11:26:52 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:
>> src/java.net.http/share/classes/jdk/internal/net/http/Stream.java line 308:
>>
>>> 306: // Have to mark request as sent, due to no request body being sent
>>> 307: // in the event of a 417 Expectation Failed
>>> 308: requestSent();
>>
>> The `requestSent()` method in `Stream` class sets a flag and only closes the Stream instance if the `responseReceived` is also set. As far as I can see in the `Stream` code, that flag plays no other major role and doesn't "trigger" any kind of action (I might be wrong though). Here, are we expecting the caller client to get a request failure (just like the `HTTP/1.1` case)? If so, should we instead of calling `Stream.completeResponseExceptionally(Throwable)` or something similar which completes the `CompletableFuture`?
>
> I think I see what we are doing here. The `Exchange` change that we did in this PR marks the `CompletableFuture` as completed with that response that was received. So the caller will see the future as completed. So the only missing piece for me now is, will the `Stream` get closed in this case, with the current change in the PR?
We need to close the stream after the exchange has terminated, but the exchange will not be considered to be terminated if we have a request body and the request body has not been sent. So we are actually pretending that the request body has been sent here in order for the stream to get gracefully closed after the final (417) response has been received.
-------------
PR: https://git.openjdk.java.net/jdk/pull/9093
More information about the net-dev
mailing list