Skip to content

Conversation

@cdw8j
Copy link
Contributor

@cdw8j cdw8j commented Sep 12, 2025

(Follow-up to pull request #555 which I messed up while trying to rebase it from 5.3.x to master.)

I have added a convenience method to the ServerBootstrap and AsyncServerBootstrap classes that configures the RequestRouter to use the LOCAL_AUTHORITY_RESOLVER scheme. While it is possible to create an HttpServer with such a custom RequestRouter within the application, this results in really messy and complicated code, which can easily be spared with this very simple convenience method.

Copy link
Member

@garydgregory garydgregory left a comment

Choose a reason for hiding this comment

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

Please see my comments.

@cdw8j cdw8j requested a review from garydgregory September 12, 2025 18:25
@ok2c ok2c force-pushed the master branch 4 times, most recently from 8fb1d8e to bf7d524 Compare September 13, 2025 16:38
@cdw8j
Copy link
Contributor Author

cdw8j commented Sep 30, 2025

Hello @garydgregory,

seems this request is in deadlock, so let me explain the background of my request.

I migrated a project from httpcore4 to httpcore5 just recently and when it didn't work, I had to dive into the httpcore5 sources to understand what was going wrong and that I need to create a custom RequestRouter with LOCAL_AUTHORITY_RESOLVER scheme to get the same behavior as before with httpcore4 just using simple ServerBootstrap methods. I might be the last on earth migrating an ancient httpcore4 application, but in this scenario and I guess also in others where the host name shall be irrelevant (and which is the reason why the LOCAL_AUTHORITY_RESOLVER scheme exists in httpcore5), it is quite a pain IMO to build the custom RequestRouter in the application itself, especially because this isn't really very well documented.

But in the end, it's not my decision, so if you decide it's not worth the API extension, then just reject the pull request and nobody will get hurt either.

@ok2c
Copy link
Member

ok2c commented Oct 1, 2025

@cdw8j Please address my comments if you want this pull request merged.

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.

@cdw8j My apologies. I actually did not submit my review last time.

Please see my comments,

}

/**
* Create {@link RequestRouter} with LOCAL_AUTHORITY_RESOLVER (default: IGNORE_PORT_AUTHORITY_RESOLVER).
Copy link
Member

Choose a reason for hiding this comment

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

@cdw8j Please do not mention LOCAL_AUTHORITY_RESOLVER and IGNORE_PORT_AUTHORITY_RESOLVER. This is an implementation details and it should be mentioned in javadocs

*
* @since 5.4
*/
public final ServerBootstrap useLocalAuthorityResolver(final boolean localAuthorityResolver) {
Copy link
Member

Choose a reason for hiding this comment

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

@cdw8j Please use a better name for the method. #routeToLocalAuthority for example.

@cdw8j
Copy link
Contributor Author

cdw8j commented Oct 2, 2025

@ok2c Re-thinking this whole thing after it has been idling a bit in my head, I wonder if it wouldn't actually make more sense to implement setter methods in the AsyncServerBootstrap and ServerBootstrap classes for an authorityResolver member that is passed to RequestRouter.create() and that defaults to to the currently used RequestRouter.IGNORE_PORT_AUTHORITY_RESOLVER. The application could then choose to call setAuthorityResolver(RequestRouter.LOCAL_AUTHORITY_RESOLVER) and setCanonicalHostName("localhost") to achieve the same behaviour as with useLocalAuthorityResolver(true) according to the current proposal.

What do you think? Should I create a separate pull request for this option and you decide which is preferrable?

@ok2c
Copy link
Member

ok2c commented Oct 2, 2025

What do you think? Should I create a separate pull request for this option and you decide which is preferrable?

@cdw8j I personally like this idea much better. If you do it fast enough there is a a good chance it will make it into the coming 5.4-alpha1 release

@cdw8j
Copy link
Contributor Author

cdw8j commented Oct 2, 2025

@ok2c not too much of a challenge :) see pull request #565

@ok2c
Copy link
Member

ok2c commented Oct 3, 2025

Superseded by #565

@ok2c ok2c closed this Oct 3, 2025
@cdw8j cdw8j deleted the feature/hc5-serverbootstrap-localauthority branch October 3, 2025 19:26
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.

3 participants