Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write Content-Length header if doForwardTrailers is not set #4259

Merged
merged 2 commits into from Apr 26, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions runtime/handler.go
Expand Up @@ -6,6 +6,7 @@ import (
"io"
"net/http"
"net/textproto"
"strconv"
"strings"

"google.golang.org/genproto/googleapis/api/httpbody"
Expand Down Expand Up @@ -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)))
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @johanbrandhorst, I've pushed a change that updates the existing tests to check for the header


if _, err = w.Write(buf); err != nil {
grpclog.Infof("Failed to write response: %v", err)
}
Expand Down