Skip to content

Commit

Permalink
Ignore non-HTTP_2 requests
Browse files Browse the repository at this point in the history
  • Loading branch information
alesj committed May 4, 2024
1 parent 016bfb5 commit c9ce425
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Pattern;

import io.vertx.core.http.HttpServerRequest;
import io.vertx.core.http.HttpVersion;
import jakarta.enterprise.inject.Instance;

import org.jboss.logging.Logger;
Expand Down Expand Up @@ -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();
}

Expand Down

0 comments on commit c9ce425

Please sign in to comment.