diff options
| author | Damien Neil <dneil@google.com> | 2026-03-03 15:34:48 -0800 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2026-03-12 08:09:54 -0700 |
| commit | dab0ba481cc35554cb1bf9658fc6140bba30cfbd (patch) | |
| tree | 71308c2f5c5519287b16704b6450e7fbf7b6456c /src/net/http/internal | |
| parent | 990896809590c4bff29b6c254433d718d4afe458 (diff) | |
| download | go-dab0ba481cc35554cb1bf9658fc6140bba30cfbd.tar.xz | |
net/http/internal/http2: use newServerTester in TestIssue53
Replace older test infrastructure with the new shiny.
Simplifies keeping this test post merge into std.
For #67810
Change-Id: Idd876af67265ae8b6ab5b82f9ac376d26a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/751306
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Nicholas Husin <husin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Nicholas Husin <nsh@golang.org>
Diffstat (limited to 'src/net/http/internal')
| -rw-r--r-- | src/net/http/internal/http2/server_test.go | 59 |
1 files changed, 9 insertions, 50 deletions
diff --git a/src/net/http/internal/http2/server_test.go b/src/net/http/internal/http2/server_test.go index 3aedddbb69..ceeba9cd37 100644 --- a/src/net/http/internal/http2/server_test.go +++ b/src/net/http/internal/http2/server_test.go @@ -3282,57 +3282,16 @@ func TestIssue53(t *testing.T) { synctestTest(t, testIssue53) } func testIssue53(t testing.TB) { const data = "PRI * HTTP/2.0\r\n\r\nSM" + "\r\n\r\n\x00\x00\x00\x01\ainfinfin\ad" - s := &http.Server{ - ErrorLog: log.New(io.MultiWriter(stderrv(), twriter{t: t}), "", log.LstdFlags), - Handler: http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { - w.Write([]byte("hello")) - }), - } - s2 := &Server{ - MaxReadFrameSize: 1 << 16, - PermitProhibitedCipherSuites: true, - } - c := &issue53Conn{[]byte(data), false, false} - s2.ServeConn(c, &ServeConnOpts{BaseConfig: s}) - if !c.closed { - t.Fatal("connection is not closed") - } -} - -type issue53Conn struct { - data []byte - closed bool - written bool -} - -func (c *issue53Conn) Read(b []byte) (n int, err error) { - if len(c.data) == 0 { - return 0, io.EOF - } - n = copy(b, c.data) - c.data = c.data[n:] - return -} - -func (c *issue53Conn) Write(b []byte) (n int, err error) { - c.written = true - return len(b), nil -} - -func (c *issue53Conn) Close() error { - c.closed = true - return nil -} - -func (c *issue53Conn) LocalAddr() net.Addr { - return &net.TCPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 49706} -} -func (c *issue53Conn) RemoteAddr() net.Addr { - return &net.TCPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 49706} + st := newServerTester(t, func(w http.ResponseWriter, req *http.Request) { + w.Write([]byte("hello")) + }) + st.cc.Write([]byte(data)) + st.wantFrameType(FrameSettings) + st.wantFrameType(FrameWindowUpdate) + st.wantFrameType(FrameGoAway) + time.Sleep(GoAwayTimeout) + st.wantClosed() } -func (c *issue53Conn) SetDeadline(t time.Time) error { return nil } -func (c *issue53Conn) SetReadDeadline(t time.Time) error { return nil } -func (c *issue53Conn) SetWriteDeadline(t time.Time) error { return nil } // golang.org/issue/12895 func TestConfigureServer(t *testing.T) { synctestTest(t, testConfigureServer) } |
