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 6, 2024
1 parent 5587d79 commit 92ced67
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
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 92ced67

Please sign in to comment.