forked from quic-go/quic-go
move the ApplicationErrorCdoe to the qerr package
This commit is contained in:
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
quic "github.com/lucas-clemente/quic-go"
|
||||
protocol "github.com/lucas-clemente/quic-go/internal/protocol"
|
||||
qerr "github.com/lucas-clemente/quic-go/internal/qerr"
|
||||
)
|
||||
|
||||
// MockEarlySession is a mock of EarlySession interface.
|
||||
@@ -68,7 +68,7 @@ func (mr *MockEarlySessionMockRecorder) AcceptUniStream(arg0 interface{}) *gomoc
|
||||
}
|
||||
|
||||
// CloseWithError mocks base method.
|
||||
func (m *MockEarlySession) CloseWithError(arg0 protocol.ApplicationErrorCode, arg1 string) error {
|
||||
func (m *MockEarlySession) CloseWithError(arg0 qerr.ApplicationErrorCode, arg1 string) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "CloseWithError", arg0, arg1)
|
||||
ret0, _ := ret[0].(error)
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
protocol "github.com/lucas-clemente/quic-go/internal/protocol"
|
||||
qerr "github.com/lucas-clemente/quic-go/internal/qerr"
|
||||
)
|
||||
|
||||
// MockStream is a mock of Stream interface.
|
||||
@@ -37,7 +38,7 @@ func (m *MockStream) EXPECT() *MockStreamMockRecorder {
|
||||
}
|
||||
|
||||
// CancelRead mocks base method.
|
||||
func (m *MockStream) CancelRead(arg0 protocol.ApplicationErrorCode) {
|
||||
func (m *MockStream) CancelRead(arg0 qerr.ApplicationErrorCode) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "CancelRead", arg0)
|
||||
}
|
||||
@@ -49,7 +50,7 @@ func (mr *MockStreamMockRecorder) CancelRead(arg0 interface{}) *gomock.Call {
|
||||
}
|
||||
|
||||
// CancelWrite mocks base method.
|
||||
func (m *MockStream) CancelWrite(arg0 protocol.ApplicationErrorCode) {
|
||||
func (m *MockStream) CancelWrite(arg0 qerr.ApplicationErrorCode) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "CancelWrite", arg0)
|
||||
}
|
||||
|
||||
@@ -52,9 +52,6 @@ const MaxByteCount = ByteCount(1<<62 - 1)
|
||||
// InvalidByteCount is an invalid byte count
|
||||
const InvalidByteCount ByteCount = -1
|
||||
|
||||
// An ApplicationErrorCode is an application-defined error code.
|
||||
type ApplicationErrorCode uint64
|
||||
|
||||
// A StatelessResetToken is a stateless reset token.
|
||||
type StatelessResetToken [16]byte
|
||||
|
||||
|
||||
@@ -46,9 +46,12 @@ func (e *TransportError) Error() string {
|
||||
return str + ": " + msg
|
||||
}
|
||||
|
||||
// An ApplicationErrorCode is an application-defined error code.
|
||||
type ApplicationErrorCode uint64
|
||||
|
||||
type ApplicationError struct {
|
||||
Remote bool
|
||||
ErrorCode uint64
|
||||
ErrorCode ApplicationErrorCode
|
||||
ErrorMessage string
|
||||
}
|
||||
|
||||
|
||||
@@ -4,13 +4,14 @@ import (
|
||||
"bytes"
|
||||
|
||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||
"github.com/lucas-clemente/quic-go/internal/qerr"
|
||||
"github.com/lucas-clemente/quic-go/quicvarint"
|
||||
)
|
||||
|
||||
// A ResetStreamFrame is a RESET_STREAM frame in QUIC
|
||||
type ResetStreamFrame struct {
|
||||
StreamID protocol.StreamID
|
||||
ErrorCode protocol.ApplicationErrorCode
|
||||
ErrorCode qerr.ApplicationErrorCode
|
||||
FinalSize protocol.ByteCount
|
||||
}
|
||||
|
||||
@@ -38,7 +39,7 @@ func parseResetStreamFrame(r *bytes.Reader, _ protocol.VersionNumber) (*ResetStr
|
||||
|
||||
return &ResetStreamFrame{
|
||||
StreamID: streamID,
|
||||
ErrorCode: protocol.ApplicationErrorCode(errorCode),
|
||||
ErrorCode: qerr.ApplicationErrorCode(errorCode),
|
||||
FinalSize: byteOffset,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
|
||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||
"github.com/lucas-clemente/quic-go/internal/qerr"
|
||||
"github.com/lucas-clemente/quic-go/quicvarint"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
@@ -22,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(protocol.ApplicationErrorCode(0x1337)))
|
||||
Expect(frame.ErrorCode).To(Equal(qerr.ApplicationErrorCode(0x1337)))
|
||||
})
|
||||
|
||||
It("errors on EOFs", func() {
|
||||
|
||||
@@ -4,13 +4,14 @@ import (
|
||||
"bytes"
|
||||
|
||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||
"github.com/lucas-clemente/quic-go/internal/qerr"
|
||||
"github.com/lucas-clemente/quic-go/quicvarint"
|
||||
)
|
||||
|
||||
// A StopSendingFrame is a STOP_SENDING frame
|
||||
type StopSendingFrame struct {
|
||||
StreamID protocol.StreamID
|
||||
ErrorCode protocol.ApplicationErrorCode
|
||||
ErrorCode qerr.ApplicationErrorCode
|
||||
}
|
||||
|
||||
// parseStopSendingFrame parses a STOP_SENDING frame
|
||||
@@ -30,7 +31,7 @@ func parseStopSendingFrame(r *bytes.Reader, _ protocol.VersionNumber) (*StopSend
|
||||
|
||||
return &StopSendingFrame{
|
||||
StreamID: protocol.StreamID(streamID),
|
||||
ErrorCode: protocol.ApplicationErrorCode(errorCode),
|
||||
ErrorCode: qerr.ApplicationErrorCode(errorCode),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
|
||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||
"github.com/lucas-clemente/quic-go/internal/qerr"
|
||||
"github.com/lucas-clemente/quic-go/quicvarint"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
@@ -20,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(protocol.ApplicationErrorCode(0x1337)))
|
||||
Expect(frame.ErrorCode).To(Equal(qerr.ApplicationErrorCode(0x1337)))
|
||||
Expect(b.Len()).To(BeZero())
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user