Make all "grpc-" metadata field names reserved (#1391)
This commit is contained in:
@ -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
|
||||||
|
@ -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 {
|
||||||
|
Reference in New Issue
Block a user