RFR: 8324209: Check implementation of Expect: 100-continue in the java.net.http.HttpClient [v4]
Darragh Clarke
dclarke at openjdk.org
Wed Aug 14 12:31:17 UTC 2024
> Currently `HttpClient` will timeout if a server doesn't respond to a request which includes `Expect: 100-Continue`
>
> Section 10.1.1 of [rfc 9110](https://datatracker.ietf.org/doc/html/rfc9110#name-expect) states that
>
> a client SHOULD NOT wait for an indefinite period before sending the content.
>
>
>
> This PR changes `HttpClient` to wait for a maximum of 5 seconds for a server response, this will be shorter if a timeout is set. If no response is received, the message will be sent regardless.
> This should bring `HttpClient` in line with how [HttpUrlConnection](https://github.com/DarraghClarke/jdk/blob/61386c199a3b29457c002ad31a23990b7f6f88fd/src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java#L1305) treats expect continue timeouts.
>
> This is done using `orTimeout` in the `expectContinue` method , though there is some changes in `streams.java` where it was possible for race conditions to cause timeouts where `CompleteableFuture`s were removed from `response_cfs` prematurely or in some cases not removed at all.
>
> I've tested this against tiers 1-3 and it appears to be stable.
Darragh Clarke has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains five commits:
- Implemented feedback and cleanup
- Merge master
- remove duplicate method
- implemented feedback
- Add timeout handling to expect-continue implementation
-------------
Changes: https://git.openjdk.org/jdk/pull/20525/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=20525&range=03
Stats: 109 lines in 4 files changed: 70 ins; 0 del; 39 mod
Patch: https://git.openjdk.org/jdk/pull/20525.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/20525/head:pull/20525
PR: https://git.openjdk.org/jdk/pull/20525
More information about the net-dev
mailing list