MCPcopy
hub / github.com/grpc/grpc-go / isReservedHeader

Function isReservedHeader

internal/transport/http_util.go:96–116  ·  view source on GitHub ↗

isReservedHeader checks whether hdr belongs to HTTP2 headers reserved by gRPC protocol. Any other headers are classified as the user-specified metadata.

(hdr string)

Source from the content-addressed store, hash-verified

94// reserved by gRPC protocol. Any other headers are classified as the
95// user-specified metadata.
96func isReservedHeader(hdr string) bool {
97 if hdr != "" && hdr[0] == ':' {
98 return true
99 }
100 switch hdr {
101 case "content-type",
102 "user-agent",
103 "grpc-message-type",
104 "grpc-encoding",
105 "grpc-message",
106 "grpc-status",
107 "grpc-timeout",
108 // Intentionally exclude grpc-previous-rpc-attempts and
109 // grpc-retry-pushback-ms, which are "reserved", but their API
110 // intentionally works via metadata.
111 "te":
112 return true
113 default:
114 return false
115 }
116}
117
118// isWhitelistedHeader checks whether hdr should be propagated into metadata
119// visible to users, even though it is classified as "reserved", above.

Callers 8

TestIsReservedHeaderMethod · 0.85
writeStatusMethod · 0.85
writeCustomHeadersMethod · 0.85
operateHeadersMethod · 0.85
appendHeaderFieldsFromMDFunction · 0.85
createHeaderFieldsMethod · 0.85
operateHeadersMethod · 0.85

Calls

no outgoing calls

Tested by 1

TestIsReservedHeaderMethod · 0.68