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

Cannot return HTTP header using "Grpc-Metadata-" prefix #782

Closed
joelurraco opened this issue Oct 17, 2018 · 2 comments
Closed

Cannot return HTTP header using "Grpc-Metadata-" prefix #782

joelurraco opened this issue Oct 17, 2018 · 2 comments

Comments

@joelurraco
Copy link

I have been using the following line of code to return HTTP headers in the server response:

import (
    "google.golang.org/grpc"
    "google.golang.org/grpc/metadata"
)

grpc.SetHeader(ctx, metadata.Pairs("Grpc-Metadata-Some-Key", someValue))

This was working OK using the runtime.DefaultHeaderMatcher when starting the server, but after updating this no longer works.

I went over the google.golang.org/grpc/metadata package and it seems that every key set in the metadata is transformed to lower case, but the runtime.DefaultHeaderMatcher function compares the transformed metadata key with the prefix "Grpc-Metadata-", so it never matches and the header is never returned.

I think this broke it.

Am I doing anything wrong? How should I set the metadata so it is returned as an HTTP header?

@johanbrandhorst
Copy link
Collaborator

Hi @joelurraco, this does indeed sound problematic. The fix seems simple enough, do you think you could contribute a fix and a new test case?

@johanbrandhorst
Copy link
Collaborator

Fixed with #784

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants