Skip to content

feat: add configurable Alt-Svc handler for HTTP/3 alternative service discovery#2910

Open
Harshal96 wants to merge 3 commits into
vert-x3:masterfrom
Harshal96:feat/alternative-services-handler
Open

feat: add configurable Alt-Svc handler for HTTP/3 alternative service discovery#2910
Harshal96 wants to merge 3 commits into
vert-x3:masterfrom
Harshal96:feat/alternative-services-handler

Conversation

@Harshal96

Copy link
Copy Markdown

Motivation:

Adds a new AltSvcHandler and AltSvcOptions API for advertising HTTP Alternative Services from Vert.x Web routes.

This enables applications to declaratively send Alt-Svc response headers for configured origins, which is useful for HTTP/3 discovery. For example:

router.route().handler(
  AltSvcHandler.create(
    new AltSvcOptions()
      .addOrigin("http://localhost:8080", "h3:localhost:8443")
  )
);

Fixes #2847

@vietj

vietj commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

@Harshal96 thanks for the contribution, the code is missing the support of HTTP/2 that works differently than with a HTTP header, I recommend you read the ALT-SVC RFC to learn more about this. For that matter you should look at HttpServerResponse#writeAltSvc method which has been added for this purpose.

@vietj vietj added this to the 5.2.0 milestone Jun 3, 2026
@Harshal96

Copy link
Copy Markdown
Author

@vietj done, can you please take a look now?

@Harshal96

Copy link
Copy Markdown
Author

@vietj is this good for another review?

* Options for configuring {@link AltSvcHandler}.
*/
@DataObject
@JsonGen(publicConverter = false)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we actually don't need JsonGen annotation here, there is no interested in having a converter for this

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

done

public class AltSvcHandlerImpl implements AltSvcHandler {

private final Map<String, String> origins;
private final Map<HttpConnection, Set<String>> announcedOrigins = new WeakHashMap<>();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we cannot reasonnably maintain such a map because it will never be cleaned from stale connections, so we need to find a way to do that properly.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

updated to remove stale connections

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Alternative services handler

2 participants