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

Function SetHeader

server.go:2102–2111  ·  view source on GitHub ↗

SetHeader sets the header metadata to be sent from the server to the client. The context provided must be the context passed to the server's handler. Streaming RPCs should prefer the SetHeader method of the ServerStream. When called multiple times, all the provided metadata will be merged. All th

(ctx context.Context, md metadata.MD)

Source from the content-addressed store, hash-verified

2100// status code will often not match the RPC status as seen by the client
2101// application, and therefore, should not be relied upon for this purpose.
2102func SetHeader(ctx context.Context, md metadata.MD) error {
2103 if md.Len() == 0 {
2104 return nil
2105 }
2106 stream := ServerTransportStreamFromContext(ctx)
2107 if stream == nil {
2108 return status.Errorf(codes.Internal, "grpc: failed to fetch the stream from the context %v", ctx)
2109 }
2110 return stream.SetHeader(md)
2111}
2112
2113// SendHeader sends header metadata. It may be called at most once, and may not
2114// be called after any event that causes headers to be sent (see SetHeader for

Callers 6

EmptyCallMethod · 0.92
UnaryCallMethod · 0.92
UnaryCallMethod · 0.92
unaryInterceptorFunction · 0.92

Calls 4

ErrorfFunction · 0.92
LenMethod · 0.65
SetHeaderMethod · 0.65