Skip to content

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

Open
@JustCryingCat

Description

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

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions