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

Method serve

internal/transport/transport_test.go:621–646  ·  view source on GitHub ↗
(t *testing.T, conn net.Conn)

Source from the content-addressed store, hash-verified

619}
620
621func (s *controllablePingServer) serve(t *testing.T, conn net.Conn) {
622 // Read frame to consume the client preface.
623 if _, err := io.ReadFull(conn, make([]byte, len(clientPreface))); err != nil {
624 t.Errorf("Error while reading client preface: %v", err)
625 return
626 }
627 // Read ping frames and ack checks.
628 framer := http2.NewFramer(conn, conn)
629 for {
630 f, err := framer.ReadFrame()
631 if err != nil {
632 return
633 }
634 if !s.pingAck.Load() {
635 return
636 }
637 pf, ok := f.(*http2.PingFrame)
638 if !ok {
639 return
640 }
641 if err := framer.WritePing(true, pf.Data); err != nil {
642 t.Errorf("Failed to write ping : %v", err)
643 return
644 }
645 }
646}
647
648func setUpControllablePingServer(t *testing.T, copts ConnectOptions, connCh chan net.Conn) (*controllablePingServer, *http2Client, func()) {
649 lis, err := net.Listen("tcp", "localhost:0")

Callers 1

Calls 2

ErrorfMethod · 0.65
LoadMethod · 0.45

Tested by

no test coverage detected