From 09c4c9c3b0c6eda29442f2aa78eb136153867088 Mon Sep 17 00:00:00 2001 From: Julien Giovaresco Date: Wed, 17 Jan 2024 09:18:21 +0100 Subject: [PATCH] fix: remove host headers in GrpcConnection https://gravitee.atlassian.net/browse/APIM-3675 --- .../java/io/gravitee/connector/http/HttpConnection.java | 2 +- .../io/gravitee/connector/http/grpc/GrpcConnection.java | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/gravitee/connector/http/HttpConnection.java b/src/main/java/io/gravitee/connector/http/HttpConnection.java index f89c8799..8b9ebc27 100644 --- a/src/main/java/io/gravitee/connector/http/HttpConnection.java +++ b/src/main/java/io/gravitee/connector/http/HttpConnection.java @@ -69,7 +69,7 @@ public class HttpConnection extends AbstractHttpConnecti HOP_HEADERS = Collections.unmodifiableSet(hopHeaders); } - private HttpClientRequest httpClientRequest; + protected HttpClientRequest httpClientRequest; private final ProxyRequest request; private T response; private Handler timeoutHandler; diff --git a/src/main/java/io/gravitee/connector/http/grpc/GrpcConnection.java b/src/main/java/io/gravitee/connector/http/grpc/GrpcConnection.java index 750a94d7..d5ee5edf 100644 --- a/src/main/java/io/gravitee/connector/http/grpc/GrpcConnection.java +++ b/src/main/java/io/gravitee/connector/http/grpc/GrpcConnection.java @@ -24,6 +24,7 @@ import io.vertx.core.Future; import io.vertx.core.http.HttpClient; import io.vertx.core.http.HttpClientRequest; +import io.vertx.core.http.HttpHeaders; import io.vertx.core.http.HttpMethod; import io.vertx.core.http.RequestOptions; @@ -60,4 +61,12 @@ protected Future prepareUpstreamRequest(HttpClient httpClient return httpClientRequest.setChunked(true); }); } + + @Override + protected void writeUpstreamHeaders() { + super.writeUpstreamHeaders(); + + // Remove host header because gRPC is HTTP/2 + httpClientRequest.headers().remove(HttpHeaders.HOST); + } }