Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public class AsyncServerBootstrap {
private IOSessionListener sessionListener;
private Http1StreamListener streamListener;
private IOReactorMetricsListener threadPoolListener;
private boolean localAuthorityResolver;

private AsyncServerBootstrap() {
this.routeEntries = new ArrayList<>();
Expand Down Expand Up @@ -435,6 +436,16 @@ public final AsyncServerBootstrap addFilterLast(final String name, final AsyncFi
return this;
}

/**
* Create {@link RequestRouter} with LOCAL_AUTHORITY_RESOLVER (default: IGNORE_PORT_AUTHORITY_RESOLVER).
*
* @since 5.4
*/
public final AsyncServerBootstrap useLocalAuthorityResolver(final boolean localAuthorityResolver) {
this.localAuthorityResolver = localAuthorityResolver;
return this;
}

public HttpAsyncServer create() {
final String actualCanonicalHostName = canonicalHostName != null ? canonicalHostName : InetAddressUtils.getCanonicalLocalHostName();
final HttpRequestMapper<Supplier<AsyncServerExchangeHandler>> requestRouterCopy;
Expand All @@ -451,9 +462,9 @@ public HttpAsyncServer create() {
requestRouterCopy = requestRouter;
} else {
requestRouterCopy = RequestRouter.create(
new URIAuthority(actualCanonicalHostName),
this.localAuthorityResolver ? RequestRouter.LOCAL_AUTHORITY : new URIAuthority(actualCanonicalHostName),
UriPatternType.URI_PATTERN, routeEntries,
RequestRouter.IGNORE_PORT_AUTHORITY_RESOLVER,
this.localAuthorityResolver ? RequestRouter.LOCAL_AUTHORITY_RESOLVER : RequestRouter.IGNORE_PORT_AUTHORITY_RESOLVER,
requestRouter);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public class ServerBootstrap {
private HttpConnectionFactory<? extends DefaultBHttpServerConnection> connectionFactory;
private ExceptionListener exceptionListener;
private Http1StreamListener streamListener;
private boolean localAuthorityResolver;

private ServerBootstrap() {
this.routeEntries = new ArrayList<>();
Expand Down Expand Up @@ -346,6 +347,16 @@ public final ServerBootstrap addFilterLast(final String name, final HttpFilterHa
return this;
}

/**
* 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.

this.localAuthorityResolver = localAuthorityResolver;
return this;
}

public HttpServer create() {
final String actualCanonicalHostName = canonicalHostName != null ? canonicalHostName : InetAddressUtils.getCanonicalLocalHostName();
final HttpRequestMapper<HttpRequestHandler> requestRouterCopy;
Expand All @@ -362,10 +373,10 @@ public HttpServer create() {
requestRouterCopy = requestRouter;
} else {
requestRouterCopy = RequestRouter.create(
new URIAuthority(actualCanonicalHostName),
this.localAuthorityResolver ? RequestRouter.LOCAL_AUTHORITY : new URIAuthority(actualCanonicalHostName),
UriPatternType.URI_PATTERN,
routeEntries,
RequestRouter.IGNORE_PORT_AUTHORITY_RESOLVER,
this.localAuthorityResolver ? RequestRouter.LOCAL_AUTHORITY_RESOLVER : RequestRouter.IGNORE_PORT_AUTHORITY_RESOLVER,
requestRouter);
}
}
Expand Down