diff --git a/runtime/handler.go b/runtime/handler.go index 8fe6a77efd5..63dc812b781 100644 --- a/runtime/handler.go +++ b/runtime/handler.go @@ -6,6 +6,7 @@ import ( "io" "net/http" "net/textproto" + "strconv" "strings" "google.golang.org/genproto/googleapis/api/httpbody" @@ -176,6 +177,10 @@ func ForwardResponseMessage(ctx context.Context, mux *ServeMux, marshaler Marsha return } + if !doForwardTrailers { + w.Header().Set("Content-Length", strconv.Itoa(len(buf))) + } + if _, err = w.Write(buf); err != nil { grpclog.Infof("Failed to write response: %v", err) }