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

make :authority propagate to MD #683

Merged
merged 3 commits into from
Jun 2, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion transport/http_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,17 @@ type decodeState struct {
mdata map[string][]string
}

// isWhitelistedHttp2Header checks whether hdr belongs to HTTP2 headers
// that should be propagated into metadata visible to users.
func isWhitelistedHttp2Header(hdr string) bool {
switch hdr {
case ":authority":
return true
default:
return false
}
}

// isReservedHeader checks whether hdr belongs to HTTP2 headers
// reserved by gRPC protocol. Any other headers are classified as the
// user-specified metadata.
Expand Down Expand Up @@ -162,7 +173,7 @@ func (d *decodeState) processHeaderField(f hpack.HeaderField) {
case ":path":
d.method = f.Value
default:
if !isReservedHeader(f.Name) {
if !isReservedHeader(f.Name) || isWhitelistedHttp2Header(f.Name) {
Copy link
Contributor

@tamird tamird May 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@isn't !isReservedHeader(":authority") already true?

EDIT: nope, disregard

if f.Name == "user-agent" {
i := strings.LastIndex(f.Value, " ")
if i == -1 {
Expand Down