Skip to content

Commit

Permalink
Uses optimized internal method to save HostAndPort allocation (#2684)
Browse files Browse the repository at this point in the history
Port of #2647 to the main branch

Signed-off-by: Thomas Segismont <[email protected]>
  • Loading branch information
tsegismont authored Nov 20, 2024
1 parent 3a0f7b6 commit e9a0665
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import io.vertx.core.buffer.Buffer;
import io.vertx.core.http.*;
import io.vertx.core.internal.ContextInternal;
import io.vertx.core.internal.http.HttpServerRequestInternal;
import io.vertx.core.internal.net.RFC3986;
import io.vertx.core.net.HostAndPort;
import io.vertx.ext.web.*;
import io.vertx.ext.web.handler.HttpException;
import io.vertx.ext.web.handler.impl.UserHolder;
Expand Down Expand Up @@ -75,9 +75,11 @@ public RoutingContextImpl(String mountPoint, RouterImpl router, HttpServerReques
}

void route() {
String path = request.path();
HostAndPort authority = request.authority();
if (authority == null && request.version() != HttpVersion.HTTP_1_0) {
final String path = request.path();
// optimized method which try hard to not allocate
final boolean hasValidAuthority = ((HttpServerRequestInternal) request).isValidAuthority();

if (!hasValidAuthority && request.version() != HttpVersion.HTTP_1_0) {
String message = HttpVersion.HTTP_1_1 == request.version() ?
"For HTTP/1.x requests, the 'Host' header is required" :
"For HTTP/2 requests, the ':authority' pseudo-header is required";
Expand Down

0 comments on commit e9a0665

Please sign in to comment.