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

fix(client): improve gRPC-Web client behavior with trailers with a space after the colon #2053

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sudorandom
Copy link

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:

grpc-status: 0
grpc-message: Message Here

But tonic-web client and server both omit the space, like:

grpc-status:0
grpc-message:Message Here

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.

… colon

According to the gRPC Web Spec, Trailers should have a space after the colon, like this:

grpc-status: 0
grpc-message: Message Here

But tonic-web client and server both omit the space, like:

grpc-status:0
grpc-message:Message Here

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 also handle the space character being there, which is what this
change does.
@sudorandom sudorandom changed the title improve gRPC-Web client behavior with trailers with a space after the colon Improve gRPC-Web client behavior with trailers with a space after the colon Nov 16, 2024
@sudorandom sudorandom changed the title Improve gRPC-Web client behavior with trailers with a space after the colon fix: improve gRPC-Web client behavior with trailers with a space after the colon Nov 16, 2024
@sudorandom sudorandom changed the title fix: improve gRPC-Web client behavior with trailers with a space after the colon fix(client): improve gRPC-Web client behavior with trailers with a space after the colon Nov 16, 2024
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

Successfully merging this pull request may close these issues.

1 participant