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

Function SendHeader

server.go:2121–2130  ·  view source on GitHub ↗

SendHeader sends header metadata. It may be called at most once, and may not be called after any event that causes headers to be sent (see SetHeader for a complete list). The provided md and headers set by SetHeader() will be sent. The error returned is compatible with the status package. However

(ctx context.Context, md metadata.MD)

Source from the content-addressed store, hash-verified

2119// status code will often not match the RPC status as seen by the client
2120// application, and therefore, should not be relied upon for this purpose.
2121func SendHeader(ctx context.Context, md metadata.MD) error {
2122 stream := ServerTransportStreamFromContext(ctx)
2123 if stream == nil {
2124 return status.Errorf(codes.Internal, "grpc: failed to fetch the stream from the context %v", ctx)
2125 }
2126 if err := stream.SendHeader(md); err != nil {
2127 return toRPCErr(err)
2128 }
2129 return nil
2130}
2131
2132// SetSendCompressor sets a compressor for outbound messages from the server.
2133// It must not be called after any event that causes headers to be sent

Callers 9

startServerMethod · 0.92
UnaryCallMethod · 0.92
EmptyCallMethod · 0.92
UnaryCallMethod · 0.92
UnaryEchoMethod · 0.92
newStatsTestStubServerFunction · 0.92

Calls 4

ErrorfFunction · 0.92
toRPCErrFunction · 0.85
SendHeaderMethod · 0.65