MCPcopy
hub / github.com/valyala/fasthttp / testServerRequests

Function testServerRequests

server_test.go:1722–1752  ·  view source on GitHub ↗
(t *testing.T, ln *fasthttputil.InmemoryListener)

Source from the content-addressed store, hash-verified

1720}
1721
1722func testServerRequests(t *testing.T, ln *fasthttputil.InmemoryListener) {
1723 conn, err := ln.Dial()
1724 if err != nil {
1725 t.Fatalf("unexpected error: %v", err)
1726 }
1727
1728 br := bufio.NewReader(conn)
1729 var resp Response
1730 for i := range 10 {
1731 if _, err = fmt.Fprintf(conn, "GET / HTTP/1.1\r\nHost: aaa\r\n\r\n"); err != nil {
1732 t.Fatalf("unexpected error on iteration %d: %v", i, err)
1733 }
1734
1735 respCh := make(chan struct{})
1736 go func() {
1737 if err = resp.Read(br); err != nil {
1738 t.Errorf("unexpected error when reading response on iteration %d: %v", i, err)
1739 }
1740 close(respCh)
1741 }()
1742 select {
1743 case <-respCh:
1744 case <-time.After(time.Second):
1745 t.Fatalf("timeout on iteration %d", i)
1746 }
1747 }
1748
1749 if err = conn.Close(); err != nil {
1750 t.Fatalf("error when closing the connection: %v", err)
1751 }
1752}
1753
1754func TestServerHTTP10ConnectionKeepAlive(t *testing.T) {
1755 t.Parallel()

Calls 4

ReadMethod · 0.95
NewReaderMethod · 0.80
CloseMethod · 0.65
DialMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…