-
Notifications
You must be signed in to change notification settings - Fork 764
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
Trailer metadata - repeated values only supported with "trailers-only" responses #1399
Comments
@jhump Thanks for the report!
Thanks for pointing out! I'm not too familiar with the spec.. But my naive understanding is that trailer is like a map (or http header) in nature, so it might/should not support multiple values for the same key, or does it? Do you have a pointer to the spec if you don't mind? In the above PR you've mentioned it might be a trivial fix? If you already exactly understand what the problem is, it might be easier for you to submit a PR in that case? 😃 |
Headers and trailers behave the same, but neither has last-writer-wins semantics. Recent versions of the HTTP specification call both headers and trailers "fields". In both headers and trailers, keys may be repeated. The effective value for a key is computed by combining the individual values. Section 5.2 of RFC 9110 addresses this directly:
|
@akshayjshah Thanks for explaining, Akshay! That makes total sense!
@jhump By any chance you can provide some quick server code example to showcase the difference between these 2 scenarios? Or maybe it can be easily demonstrated using our interop or unit test? https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/grpcwebclientbase_test.js Thanks! |
If a gRPC response sets multiple values for the same trailer key, split across multiple lines, all of the values are available (via the
metadata
property of the status) if the response arrives as a "trailers-only" response (meaning that the trailers are all encoded as HTTP headers and there is no body).But if the trailer metadata arrives in the body, as the final special message in the stream, only the final value is made available, as if the others were never even present. Most likely, a simple map (key -> singular string value) is being used to process the final message, so later values are incorrectly overwriting earlier ones.
The text was updated successfully, but these errors were encountered: