Skip to content

Conversation

@arturobernalg
Copy link
Member

Introduces EarlyHintsListener to surface 103 Early Hints without altering final response flow.

Wires listener via HttpClientBuilder#setEarlyHintsListener(...) and HttpAsyncClientBuilder#setEarlyHintsListener(...).

Handles 103 in classic (MainClientExec) and async (EarlyHintsAsyncExec).

Early Hints (RFC 8297) allows servers to advise clients (typically via Link preload/preconnect) before the final response. Libraries should expose these hints while keeping normal processing intact.

@arturobernalg arturobernalg requested a review from ok2c August 16, 2025 11:28
@garydgregory
Copy link
Member

garydgregory commented Aug 16, 2025

Hi all,

The page https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/103 suggests 103 should only be for HTTP/2 or later. Should this PR only apply to HTTP/2?

@arturobernalg
Copy link
Member Author

Hi all,

The page https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/103 suggests 103 should only be for HTTP/2 or later. Should this PR only apply to HTTP/2?

For what I understand MDN’s note is a deployment recommendation, not a protocol limit. RFC 8297 does not restrict 103 to HTTP/2+

@garydgregory
Copy link
Member

Hi all,
The page https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/103 suggests 103 should only be for HTTP/2 or later. Should this PR only apply to HTTP/2?

For what I understand MDN’s note is a deployment recommendation, not a protocol limit. RFC 8297 does not restrict 103 to HTTP/2+

Check. I wonder if the fact that this is an RFC marked "Experimental" should be of concern, or at least mentioned in the Javadoc.

@arturobernalg
Copy link
Member Author

Hi all,

The page https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/103 suggests 103 should only be for HTTP/2 or later. Should this PR only apply to HTTP/2?

For what I understand MDN’s note is a deployment recommendation, not a protocol limit. RFC 8297 does not restrict 103 to HTTP/2+

Check. I wonder if the fact that this is an RFC marked "Experimental" should be of concern, or at least mentioned in the Javadoc.

The RFC text is immutable, so the body still says “Experimental” (that’s the original 2017 publication). However, the IESG later changed the status to Proposed Standard; that action is recorded separately and Datatracker now shows the badge accordingly. Official status-change doc (Feb 5, 2025) is here. 
For reference, the original RFC body that still reads “Experimental” is here (unchanged by design).

@garydgregory
Copy link
Member

Thank you for the details @arturobernalg 👌

@rschmitt
Copy link
Contributor

The page https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/103 suggests 103 should only be for HTTP/2 or later.

And rightly so. HTTP/1.1's framing is inherently unreliable and they're still finding desync attacks in the wild. Additionally, this type of scheme works best with async IO, so that the 103 response can be handled as soon as it comes in, and only HTTP/2 is reliably implemented with async IO (since it's a multiplexed protocol). I also find it strange that this RFC provides no way for the client to signal its support for this feature, analogous to Expect: 100-continue. Who the hell would just turn this feature on in production for all clients?

I agree that the client should at least tolerate 103 responses, but I don't have a strong opinion about how to expose them. The dedicated callback in the PR seems reasonable.

@ok2c
Copy link
Member

ok2c commented Oct 11, 2025

@arturobernalg I agree with @rschmitt I would not add this feature to the classic transport at all. The implementation for the classic i/o looks clumsy and it is not worth it.

@arturobernalg
Copy link
Member Author

@arturobernalg I agree with @rschmitt I would not add this feature to the classic transport at all. The implementation for the classic i/o looks clumsy and it is not worth it.

@ok2c I’ll scope Early Hints to the async client only and drop the classic wiring.

@ok2c ok2c force-pushed the master branch 2 times, most recently from 4a34b97 to 26d51f6 Compare October 14, 2025 12:48
Copy link
Member

@ok2c ok2c left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arturobernalg Looks good overall. An example / sample app would be nice, though.

final AsyncEntityProducer entityProducer,
final AsyncExecChain.Scope scope,
final AsyncExecChain chain,
final AsyncExecCallback callback) throws HttpException, java.io.IOException {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arturobernalg Why full class name?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arturobernalg This one still uses full class name. Should it?

@arturobernalg arturobernalg force-pushed the earlyHints branch 2 times, most recently from 6ce04b9 to 66db92a Compare October 15, 2025 17:07
@arturobernalg arturobernalg requested a review from ok2c October 15, 2025 17:19
@arturobernalg arturobernalg requested a review from ok2c October 16, 2025 06:39
@ok2c ok2c changed the title Add RFC 8297 (103 Early Hints) support to HttpClient5 (classic & async) Add RFC 8297 (103 Early Hints) support to HttpClient5 (async) Oct 16, 2025
Copy link
Member

@ok2c ok2c left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arturobernalg There is still one unresolved comment

Expose EarlyHintsListener + builder hooks ( only for async)
Deliver 103 via EarlyHintsAsyncExec; final response unchanged
@arturobernalg
Copy link
Member Author

@arturobernalg There is still one unresolved comment

solve. sorry @ok2c I overlooked it

@arturobernalg arturobernalg requested a review from ok2c October 16, 2025 13:57
@arturobernalg arturobernalg merged commit f4027e7 into apache:master Oct 18, 2025
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants