diff --git a/http3/client.go b/http3/client.go index f5ae83322..3a5df2552 100644 --- a/http3/client.go +++ b/http3/client.go @@ -127,6 +127,9 @@ func (c *client) setupSession() error { } func (c *client) Close() error { + if c.session == nil { + return nil + } return c.session.CloseWithError(quic.ErrorCode(errorNoError), "") } diff --git a/http3/client_test.go b/http3/client_test.go index 8b2dee279..4f1e2296f 100644 --- a/http3/client_test.go +++ b/http3/client_test.go @@ -146,6 +146,12 @@ var _ = Describe("Client", func() { Expect(err).To(MatchError(testErr)) }) + It("closes correctly if session was not created", func() { + client = newClient("localhost:1337", nil, &roundTripperOpts{}, nil, nil) + err := client.Close() + Expect(err).ToNot(HaveOccurred()) + }) + Context("Doing requests", func() { var ( request *http.Request