connectrpc / connect-go

The Go implementation of Connect: Protobuf RPC that works.
https://connectrpc.com
Apache License 2.0
2.76k stars 91 forks source link

Only use trailers-only response in grpc-web when there are no custom headers #677

Closed jhump closed 5 months ago

jhump commented 5 months ago

I pulled this commit into the conformance repo to verify that this change is compatible with the official gRPC-Web JS client. In fact, I added some conformance test cases around it (https://github.com/connectrpc/conformance/pull/770) to verify that a gRPC-Web client will correctly accept both forms of "empty" response (for both unary and streams): 1) Headers, no response messages, trailers in the body 2) Trailers-only (where trailers are in HTTP headers)

The only issue with the gRPC-Web JS client was that it doesn't like it when in-body trailers contains a key more than once. It doesn't fail, but later values overwrite earlier ones instead of it merging all of the values. (I went ahead and filed a bug for it: https://github.com/grpc/grpc-web/issues/1399. It's trivial to fix, so I might open a pull request, too.)