perf(core): look up the authority only for an HTTP/1.0 request in the missing Host check (#8443)

This commit is contained in:
TATSUNO “Taz” Yasuhiro authored and GitHub committed 2026-11-15 08:34:23 -04:00
1 parent e9f842765d
commit f5e08d5e9c
2 files changed
+20 -2

No files matched your search

@@ -2,6 +2,7 @@ package io.floci.aws.core.common;
import io.quarkus.vertx.http.runtime.CurrentVertxRequest;
import io.vertx.core.http.HttpServerRequest;
import io.vertx.core.http.HttpVersion;
import io.vertx.core.net.SocketAddress;
import io.vertx.ext.web.RoutingContext;
import jakarta.annotation.Priority;
@@ -68,9 +69,11 @@ public class MissingHostHeaderFilter implements ContainerRequestFilter {
if (routingContext == null) {
return;
}
// An HTTP/2 request has no Host header either, but carries :authority, which Vert.x
// surfaces here. A null authority is the one case with nothing to route by.
HttpServerRequest request = routingContext.request();
// vertx-web answers 400 to any other version without a valid authority before a filter runs.
if (request.version() != HttpVersion.HTTP_1_0) {
return;
}
if (request.authority() != null) {
return;
}
@@ -64,6 +64,21 @@ class MissingHostHeaderIntegrationTest {
}
}
@Test
void http10WithInvalidHostHeaderServesHealth() throws Exception {
String response = rawRequest("GET /_floci/health HTTP/1.0\r\nHost: a b\r\n\r\n");
assertThat(response, startsWith("HTTP/1.0 200 OK"));
}
@Test
void http11WithInvalidHostHeaderIsRejected() throws Exception {
String response = rawRequest(
"GET /_floci/health HTTP/1.1\r\nHost: a b\r\nConnection: close\r\n\r\n");
assertThat(response, startsWith("HTTP/1.1 400 Bad Request"));
}
@Test
void http11WithoutHostHeaderIsRejected() throws Exception {
String response = rawRequest("GET /_floci/health HTTP/1.1\r\nConnection: close\r\n\r\n");