fix(client): improve gRPC-Web client behavior with trailers with a space after the colon #2053
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
This was reported to me here: sudorandom/fauxrpc#15.
According to the gRPC Web spec, trailers should have a space after the colon, like this:
But tonic-web client and server both omit the space, like:
This is likely fine for the server to do since most clients can handle having the space or not but the tonic-web client should handle the space character being there (or not), which is what this change does.
Solution
The solution is to trim a space character from the trailer value, if it exists so that both formats are supported using the tonic-web client.
I am extremely new to rust, so feel free to close this PR or modify it in favor of a more conventionally rusty approach.