From 92ced67c711367e50f646344fd985b3f2a9046b7 Mon Sep 17 00:00:00 2001 From: Ales Justin Date: Sat, 4 May 2024 07:56:15 +0200 Subject: [PATCH] Ignore non-HTTP_2 requests --- .../io/quarkus/grpc/runtime/GrpcServerRecorder.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/GrpcServerRecorder.java b/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/GrpcServerRecorder.java index 54e83ead17432..322cf5eb18db7 100644 --- a/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/GrpcServerRecorder.java +++ b/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/GrpcServerRecorder.java @@ -68,6 +68,8 @@ import io.vertx.core.Handler; import io.vertx.core.Promise; import io.vertx.core.Vertx; +import io.vertx.core.http.HttpServerRequest; +import io.vertx.core.http.HttpVersion; import io.vertx.ext.web.Route; import io.vertx.ext.web.Router; import io.vertx.ext.web.RoutingContext; @@ -216,7 +218,13 @@ public void handle(Void unused) { // TODO -- handle Avro, plain text ... when supported / needed private static boolean isGrpc(RoutingContext rc) { - String header = rc.request().getHeader("content-type"); + HttpServerRequest request = rc.request(); + HttpVersion version = request.version(); + if (HttpVersion.HTTP_1_0.equals(version) || HttpVersion.HTTP_1_1.equals(version)) { + LOGGER.debugf("Expecting %s, received %s - not a gRPC request", HttpVersion.HTTP_2, version); + return false; + } + String header = request.getHeader("content-type"); return header != null && GRPC_CONTENT_TYPE.matcher(header.toLowerCase(Locale.ROOT)).matches(); }