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

Lack of grpc Trailers-Only support in the wrapHandler function #1164

Open
JustCryingCat opened this issue Apr 18, 2023 · 0 comments
Open

Lack of grpc Trailers-Only support in the wrapHandler function #1164

JustCryingCat opened this issue Apr 18, 2023 · 0 comments

Comments

@JustCryingCat
Copy link

JustCryingCat commented Apr 18, 2023

Versions of relevant software used
v0.15.0

What happened
The wrapHandler function does not check Trailers-Only case and adds extra data to trailers.

func (w *grpcWebResponse) copyTrailersToPayload() {
trailers := extractTrailingHeaders(w.headers, w.wrapped.Header())
trailerBuffer := new(bytes.Buffer)
trailers.Write(trailerBuffer)
trailerGrpcDataHeader := []byte{1 << 7, 0, 0, 0, 0} // MSB=1 indicates this is a trailer data frame.
binary.BigEndian.PutUint32(trailerGrpcDataHeader[1:5], uint32(trailerBuffer.Len()))
w.wrapped.Write(trailerGrpcDataHeader)
w.wrapped.Write(trailerBuffer.Bytes())
flushWriter(w.wrapped)
}

It's about line 101

Instead of empty trailers in the case of Trailers-Only, I get a trailer with 0x80 0x0 0x0 0x0 0x0

What you expected to happen
In the case of Trailers-Only, Trailer must remain empty. In the response from the server only headers are involved

How to reproduce it (as minimally and precisely as possible):
Your library uses the traefik gateway, which allows the case of Trailers-Only.

https://github.com/traefik/traefik/blob/8174860770e536b4afb541e0ab13b3611a101430/pkg/middlewares/grpcweb/grpcweb.go#L15-L26

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant