forked from quic-go/quic-go
pass a string, not an error, to Session.CloseWithError
This commit is contained in:
@@ -87,7 +87,8 @@ func (c *client) dial() error {
|
|||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
if err := c.setupSession(); err != nil {
|
if err := c.setupSession(); err != nil {
|
||||||
c.session.CloseWithError(quic.ErrorCode(errorInternalError), err)
|
c.logger.Debugf("Setting up session failed: %s", err)
|
||||||
|
c.session.CloseWithError(quic.ErrorCode(errorInternalError), "")
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ var _ = Describe("RoundTripper", func() {
|
|||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
session.EXPECT().OpenUniStreamSync().AnyTimes().Return(nil, testErr)
|
session.EXPECT().OpenUniStreamSync().AnyTimes().Return(nil, testErr)
|
||||||
session.EXPECT().OpenStreamSync().Return(nil, testErr)
|
session.EXPECT().OpenStreamSync().Return(nil, testErr)
|
||||||
session.EXPECT().CloseWithError(gomock.Any(), gomock.Any()).Do(func(quic.ErrorCode, error) { close(closed) })
|
session.EXPECT().CloseWithError(gomock.Any(), gomock.Any()).Do(func(quic.ErrorCode, string) { close(closed) })
|
||||||
_, err = rt.RoundTrip(req)
|
_, err = rt.RoundTrip(req)
|
||||||
Expect(err).To(MatchError(testErr))
|
Expect(err).To(MatchError(testErr))
|
||||||
Expect(rt.clients).To(HaveLen(1))
|
Expect(rt.clients).To(HaveLen(1))
|
||||||
@@ -130,7 +130,7 @@ var _ = Describe("RoundTripper", func() {
|
|||||||
testErr := errors.New("test err")
|
testErr := errors.New("test err")
|
||||||
session.EXPECT().OpenUniStreamSync().AnyTimes().Return(nil, testErr)
|
session.EXPECT().OpenUniStreamSync().AnyTimes().Return(nil, testErr)
|
||||||
session.EXPECT().OpenStreamSync().Return(nil, testErr).Times(2)
|
session.EXPECT().OpenStreamSync().Return(nil, testErr).Times(2)
|
||||||
session.EXPECT().CloseWithError(gomock.Any(), gomock.Any()).Do(func(quic.ErrorCode, error) { close(closed) })
|
session.EXPECT().CloseWithError(gomock.Any(), gomock.Any()).Do(func(quic.ErrorCode, string) { close(closed) })
|
||||||
req, err := http.NewRequest("GET", "https://quic.clemente.io/file1.html", nil)
|
req, err := http.NewRequest("GET", "https://quic.clemente.io/file1.html", nil)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
_, err = rt.RoundTrip(req)
|
_, err = rt.RoundTrip(req)
|
||||||
|
|||||||
@@ -155,8 +155,8 @@ type Session interface {
|
|||||||
// Close the connection.
|
// Close the connection.
|
||||||
io.Closer
|
io.Closer
|
||||||
// Close the connection with an error.
|
// Close the connection with an error.
|
||||||
// The error must not be nil.
|
// The error string will be sent to the peer.
|
||||||
CloseWithError(ErrorCode, error) error
|
CloseWithError(ErrorCode, string) error
|
||||||
// The context is cancelled when the session is closed.
|
// The context is cancelled when the session is closed.
|
||||||
// Warning: This API should not be considered stable and might change soon.
|
// Warning: This API should not be considered stable and might change soon.
|
||||||
Context() context.Context
|
Context() context.Context
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ func (mr *MockSessionMockRecorder) Close() *gomock.Call {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CloseWithError mocks base method
|
// CloseWithError mocks base method
|
||||||
func (m *MockSession) CloseWithError(arg0 protocol.ApplicationErrorCode, arg1 error) error {
|
func (m *MockSession) CloseWithError(arg0 protocol.ApplicationErrorCode, arg1 string) error {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "CloseWithError", arg0, arg1)
|
ret := m.ctrl.Call(m, "CloseWithError", arg0, arg1)
|
||||||
ret0, _ := ret[0].(error)
|
ret0, _ := ret[0].(error)
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ func (mr *MockQuicSessionMockRecorder) Close() *gomock.Call {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CloseWithError mocks base method
|
// CloseWithError mocks base method
|
||||||
func (m *MockQuicSession) CloseWithError(arg0 protocol.ApplicationErrorCode, arg1 error) error {
|
func (m *MockQuicSession) CloseWithError(arg0 protocol.ApplicationErrorCode, arg1 string) error {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "CloseWithError", arg0, arg1)
|
ret := m.ctrl.Call(m, "CloseWithError", arg0, arg1)
|
||||||
ret0, _ := ret[0].(error)
|
ret0, _ := ret[0].(error)
|
||||||
|
|||||||
@@ -891,8 +891,8 @@ func (s *session) Close() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *session) CloseWithError(code protocol.ApplicationErrorCode, e error) error {
|
func (s *session) CloseWithError(code protocol.ApplicationErrorCode, desc string) error {
|
||||||
s.closeLocal(qerr.Error(qerr.ErrorCode(code), e.Error()))
|
s.closeLocal(qerr.Error(qerr.ErrorCode(code), desc))
|
||||||
<-s.ctx.Done()
|
<-s.ctx.Done()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -405,7 +405,7 @@ var _ = Describe("Session", func() {
|
|||||||
sessionRunner.EXPECT().Retire(gomock.Any())
|
sessionRunner.EXPECT().Retire(gomock.Any())
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
||||||
sess.CloseWithError(0x1337, testErr)
|
sess.CloseWithError(0x1337, testErr.Error())
|
||||||
Eventually(areSessionsRunning).Should(BeFalse())
|
Eventually(areSessionsRunning).Should(BeFalse())
|
||||||
Expect(sess.Context().Done()).To(BeClosed())
|
Expect(sess.Context().Done()).To(BeClosed())
|
||||||
})
|
})
|
||||||
@@ -1191,7 +1191,7 @@ var _ = Describe("Session", func() {
|
|||||||
sessionRunner.EXPECT().Retire(gomock.Any())
|
sessionRunner.EXPECT().Retire(gomock.Any())
|
||||||
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
packer.EXPECT().PackConnectionClose(gomock.Any()).Return(&packedPacket{}, nil)
|
||||||
cryptoSetup.EXPECT().Close()
|
cryptoSetup.EXPECT().Close()
|
||||||
Expect(sess.CloseWithError(0x1337, testErr)).To(Succeed())
|
Expect(sess.CloseWithError(0x1337, testErr.Error())).To(Succeed())
|
||||||
Eventually(done).Should(BeClosed())
|
Eventually(done).Should(BeClosed())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user