diff options
| author | Damien Neil <dneil@google.com> | 2026-03-24 08:18:27 -0700 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2026-03-24 08:48:09 -0700 |
| commit | abd44cbe615ecea5e4bd8e6d1bb7be63d1f4b2d6 (patch) | |
| tree | c17a4519c2c402bc9ab981e86e5cb662ba18279e /src/net | |
| parent | c7e151d8c46dbf45b580a73ccb5ba5dd5b5cddef (diff) | |
| download | go-abd44cbe615ecea5e4bd8e6d1bb7be63d1f4b2d6.tar.xz | |
net/http: add a test for starting a server with no HTTP/2 and no TLS config
Test for the fix in CL 758560.
Change-Id: I34edf9f14dc5d6a569f20aa3d55d9d136a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/758661
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Nicholas Husin <nsh@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Nicholas Husin <husin@google.com>
Diffstat (limited to 'src/net')
| -rw-r--r-- | src/net/http/serve_test.go | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/net/http/serve_test.go b/src/net/http/serve_test.go index b2cf43cd3f..f2ba8705d1 100644 --- a/src/net/http/serve_test.go +++ b/src/net/http/serve_test.go @@ -18,7 +18,6 @@ import ( "encoding/json" "errors" "fmt" - "internal/synctest" "internal/testenv" "io" "log" @@ -44,6 +43,7 @@ import ( "sync/atomic" "syscall" "testing" + "testing/synctest" "time" ) @@ -7648,3 +7648,17 @@ func testServerTLSNextProtos(t *testing.T, mode testMode) { t.Fatalf("after running test: original NextProtos slice = %v, want %v", nextProtos, wantNextProtos) } } + +// Verifies that starting a server with HTTP/2 disabled and an empty TLSConfig does not panic. +// (Tests fix in CL 758560.) +func TestServerHTTP2Disabled(t *testing.T) { + synctest.Test(t, func(t *testing.T) { + li := fakeNetListen() + srv := &Server{} + srv.Protocols = new(Protocols) + srv.Protocols.SetHTTP1(true) + go srv.ServeTLS(li, "", "") + synctest.Wait() + srv.Shutdown(t.Context()) + }) +} |
