(t *testing.T, conn net.Conn)
| 619 | } |
| 620 | |
| 621 | func (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 | |
| 648 | func setUpControllablePingServer(t *testing.T, copts ConnectOptions, connCh chan net.Conn) (*controllablePingServer, *http2Client, func()) { |
| 649 | lis, err := net.Listen("tcp", "localhost:0") |
no test coverage detected