Make all "grpc-" metadata field names reserved (#1391)

This commit is contained in:
dfawley
2017-07-26 10:50:56 -07:00
committed by GitHub
parent 0c390d8eea
commit 3ddcdc268d
2 changed files with 7 additions and 12 deletions

View File

@ -121,19 +121,14 @@ func isReservedHeader(hdr string) bool {
if hdr != "" && hdr[0] == ':' { if hdr != "" && hdr[0] == ':' {
return true return true
} }
switch hdr { if strings.HasPrefix(hdr, "grpc-") {
case "content-type",
"grpc-message-type",
"grpc-encoding",
"grpc-message",
"grpc-status",
"grpc-timeout",
"grpc-status-details-bin",
"te":
return true return true
default:
return false
} }
switch hdr {
case "content-type", "te":
return true
}
return false
} }
// isWhitelistedPseudoHeader checks whether hdr belongs to HTTP2 pseudoheaders // isWhitelistedPseudoHeader checks whether hdr belongs to HTTP2 pseudoheaders

View File

@ -1577,7 +1577,7 @@ func TestIsReservedHeader(t *testing.T) {
{"grpc-encoding", true}, {"grpc-encoding", true},
{"grpc-message", true}, {"grpc-message", true},
{"grpc-status", true}, {"grpc-status", true},
{"grpc-timeout", true}, {"grpc-anything-else99999", true},
{"te", true}, {"te", true},
} }
for _, tt := range tests { for _, tt := range tests {