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

Method write

internal/transport/handler_server.go:336–358  ·  view source on GitHub ↗
(s *ServerStream, hdr []byte, data mem.BufferSlice, _ *WriteOptions)

Source from the content-addressed store, hash-verified

334}
335
336func (ht *serverHandlerTransport) write(s *ServerStream, hdr []byte, data mem.BufferSlice, _ *WriteOptions) error {
337 // Always take a reference because otherwise there is no guarantee the data will
338 // be available after this function returns. This is what callers to Write
339 // expect.
340 data.Ref()
341 headersWritten := s.updateHeaderSent()
342 err := ht.do(func() {
343 defer data.Free()
344 if !headersWritten {
345 ht.writePendingHeaders(s)
346 }
347 ht.rw.Write(hdr)
348 for _, b := range data {
349 _, _ = ht.rw.Write(b.ReadOnlyData())
350 }
351 ht.rw.(http.Flusher).Flush()
352 })
353 if err != nil {
354 data.Free()
355 return err
356 }
357 return nil
358}
359
360func (ht *serverHandlerTransport) writeHeader(s *ServerStream, md metadata.MD) error {
361 if err := s.SetHeader(md); err != nil {

Callers

nothing calls this directly

Calls 8

doMethod · 0.95
writePendingHeadersMethod · 0.95
updateHeaderSentMethod · 0.80
RefMethod · 0.65
FreeMethod · 0.65
WriteMethod · 0.65
ReadOnlyDataMethod · 0.65
FlushMethod · 0.65

Tested by

no test coverage detected