forked from quic-go/quic-go
introduce a quic.StreamError type and use it for stream cancelations
This commit is contained in:
@@ -38,7 +38,7 @@ func (m *MockStream) EXPECT() *MockStreamMockRecorder {
|
||||
}
|
||||
|
||||
// CancelRead mocks base method.
|
||||
func (m *MockStream) CancelRead(arg0 qerr.ApplicationErrorCode) {
|
||||
func (m *MockStream) CancelRead(arg0 qerr.StreamErrorCode) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "CancelRead", arg0)
|
||||
}
|
||||
@@ -50,7 +50,7 @@ func (mr *MockStreamMockRecorder) CancelRead(arg0 interface{}) *gomock.Call {
|
||||
}
|
||||
|
||||
// CancelWrite mocks base method.
|
||||
func (m *MockStream) CancelWrite(arg0 qerr.ApplicationErrorCode) {
|
||||
func (m *MockStream) CancelWrite(arg0 qerr.StreamErrorCode) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "CancelWrite", arg0)
|
||||
}
|
||||
|
||||
@@ -52,6 +52,9 @@ func (e *TransportError) Error() string {
|
||||
// An ApplicationErrorCode is an application-defined error code.
|
||||
type ApplicationErrorCode uint64
|
||||
|
||||
// A StreamErrorCode is an error code used to cancel streams.
|
||||
type StreamErrorCode uint64
|
||||
|
||||
type ApplicationError struct {
|
||||
Remote bool
|
||||
ErrorCode ApplicationErrorCode
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
// A ResetStreamFrame is a RESET_STREAM frame in QUIC
|
||||
type ResetStreamFrame struct {
|
||||
StreamID protocol.StreamID
|
||||
ErrorCode qerr.ApplicationErrorCode
|
||||
ErrorCode qerr.StreamErrorCode
|
||||
FinalSize protocol.ByteCount
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ func parseResetStreamFrame(r *bytes.Reader, _ protocol.VersionNumber) (*ResetStr
|
||||
|
||||
return &ResetStreamFrame{
|
||||
StreamID: streamID,
|
||||
ErrorCode: qerr.ApplicationErrorCode(errorCode),
|
||||
ErrorCode: qerr.StreamErrorCode(errorCode),
|
||||
FinalSize: byteOffset,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ var _ = Describe("RESET_STREAM frame", func() {
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(frame.StreamID).To(Equal(protocol.StreamID(0xdeadbeef)))
|
||||
Expect(frame.FinalSize).To(Equal(protocol.ByteCount(0x987654321)))
|
||||
Expect(frame.ErrorCode).To(Equal(qerr.ApplicationErrorCode(0x1337)))
|
||||
Expect(frame.ErrorCode).To(Equal(qerr.StreamErrorCode(0x1337)))
|
||||
})
|
||||
|
||||
It("errors on EOFs", func() {
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
// A StopSendingFrame is a STOP_SENDING frame
|
||||
type StopSendingFrame struct {
|
||||
StreamID protocol.StreamID
|
||||
ErrorCode qerr.ApplicationErrorCode
|
||||
ErrorCode qerr.StreamErrorCode
|
||||
}
|
||||
|
||||
// parseStopSendingFrame parses a STOP_SENDING frame
|
||||
@@ -31,7 +31,7 @@ func parseStopSendingFrame(r *bytes.Reader, _ protocol.VersionNumber) (*StopSend
|
||||
|
||||
return &StopSendingFrame{
|
||||
StreamID: protocol.StreamID(streamID),
|
||||
ErrorCode: qerr.ApplicationErrorCode(errorCode),
|
||||
ErrorCode: qerr.StreamErrorCode(errorCode),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ var _ = Describe("STOP_SENDING frame", func() {
|
||||
frame, err := parseStopSendingFrame(b, versionIETFFrames)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(frame.StreamID).To(Equal(protocol.StreamID(0xdecafbad)))
|
||||
Expect(frame.ErrorCode).To(Equal(qerr.ApplicationErrorCode(0x1337)))
|
||||
Expect(frame.ErrorCode).To(Equal(qerr.StreamErrorCode(0x1337)))
|
||||
Expect(b.Len()).To(BeZero())
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user