proxy: set Content-Type for gRPC requests

Prior we would not set the Content-Type header for
grpc request, which on failure events would cause
the response to be invalid gRPC responses, as the
grpc code path in sendDirectResponse expects the
Content-Type header to be set.

This change fixes the problem by setting the
Content-Type header to application/grpc for gRPC
requests.
This commit is contained in:
sputn1ck
2025-05-14 18:27:02 +02:00
parent a4d7a023c9
commit 324c27dd55

View File

@@ -134,6 +134,12 @@ func (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}
// If the request is a gRPC request, we need to set the Content-Type
// header to application/grpc.
if strings.HasPrefix(r.Header.Get(hdrContentType), hdrTypeGrpc) {
w.Header().Set(hdrContentType, hdrTypeGrpc)
}
// Requests that can't be matched to a service backend will be
// dispatched to the static file server. If the file exists in the
// static file folder it will be served, otherwise the static server