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

Method SetHeader

internal/transport/server_stream.go:154–165  ·  view source on GitHub ↗

SetHeader sets the header metadata. This can be called multiple times. This should not be called in parallel to other data writes.

(md metadata.MD)

Source from the content-addressed store, hash-verified

152// SetHeader sets the header metadata. This can be called multiple times.
153// This should not be called in parallel to other data writes.
154func (s *ServerStream) SetHeader(md metadata.MD) error {
155 if md.Len() == 0 {
156 return nil
157 }
158 if s.isHeaderSent() || s.getState() == streamDone {
159 return ErrIllegalHeaderWrite
160 }
161 s.hdrMu.Lock()
162 s.header = metadata.Join(s.header, md)
163 s.hdrMu.Unlock()
164 return nil
165}
166
167// SetTrailer sets the trailer metadata which will be sent with the RPC status
168// by the server. This can be called multiple times.

Callers

nothing calls this directly

Implementers 1

serverStreamstream.go

Calls 6

isHeaderSentMethod · 0.95
JoinFunction · 0.92
LenMethod · 0.65
getStateMethod · 0.45
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected