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

forwarding binary metadata is broken #218

Closed
kazegusuri opened this issue Aug 20, 2016 · 2 comments
Closed

forwarding binary metadata is broken #218

kazegusuri opened this issue Aug 20, 2016 · 2 comments
Labels

Comments

@kazegusuri
Copy link
Contributor

gRPC can handle binary metadata with -bin suffix key. The value is encoded to base64 before sending metadata and decoded by receiver implicitly. grpc-gateway now forwards all metadata values as is. Non-ASCII values are dropped as a result.

Is there a right way to handle binary header value in HTTP/1.1? Or how about just encoding binary metadata to base64? Once determined I will fix the code with pleasure :)

@yugui yugui added the bug label Sep 17, 2016
@tmc
Copy link
Collaborator

tmc commented Jun 19, 2018

I know this is super old but yes base64 encoding seems like a fine path.

@vaijab
Copy link

vaijab commented Aug 7, 2018

I have been fiddling with this myself. There is no easy way to send bytes in a header value with curl (for example) over HTTP/1.1. Normally this would be base64 encoded, which is what happens in HTTP/2 transport implicitly.

For example, let's consider an HTTP/1.1 header called grpc-metadata-foo-bin. When grpc-gateway receives an HTTP/1.1 request with mentioned header, it will strip grpc-metadata- prefix and will pass the header to gRPC call via gRPC metadata.

gRPC HTTP/2 transport layer will base64 encode header (named with -bin suffix) value before putting it on the wire, same happens on the other end - the value gets decoded.

So here is the catch, if you simply do curl -H 'grpc-metadata-foo-bin: <base64-encoded-value>', gRPC transport layer will just base64 encode the value again, which is not what we wanted to see.

I think, that grpc-gateway should be a little smarter when it comes to headers names with -bin suffix. What the gateway should do is to expect -bin header value to be base64 encoded and decode it before making a gRPC call.

Thoughts?

timonwong added a commit to timonwong/grpc-gateway that referenced this issue Aug 27, 2018
timonwong added a commit to timonwong/grpc-gateway that referenced this issue Aug 29, 2018
adasari pushed a commit to adasari/grpc-gateway that referenced this issue Apr 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants