mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-03 20:27:35 +03:00
rename stream.AddStreamFrame to stream.HandleStreamFrame
This commit is contained in:
parent
975e45d2e1
commit
823098d6e2
6 changed files with 53 additions and 53 deletions
|
@ -11,7 +11,7 @@ import (
|
|||
type cryptoStreamI interface {
|
||||
io.Reader
|
||||
io.Writer
|
||||
AddStreamFrame(*wire.StreamFrame) error
|
||||
HandleStreamFrame(*wire.StreamFrame) error
|
||||
PopStreamFrame(protocol.ByteCount) *wire.StreamFrame
|
||||
Cancel(error)
|
||||
HasDataForWriting() bool
|
||||
|
|
|
@ -36,18 +36,6 @@ func (_m *MockStreamI) EXPECT() *MockStreamIMockRecorder {
|
|||
return _m.recorder
|
||||
}
|
||||
|
||||
// AddStreamFrame mocks base method
|
||||
func (_m *MockStreamI) AddStreamFrame(_param0 *wire.StreamFrame) error {
|
||||
ret := _m.ctrl.Call(_m, "AddStreamFrame", _param0)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// AddStreamFrame indicates an expected call of AddStreamFrame
|
||||
func (_mr *MockStreamIMockRecorder) AddStreamFrame(arg0 interface{}) *gomock.Call {
|
||||
return _mr.mock.ctrl.RecordCallWithMethodType(_mr.mock, "AddStreamFrame", reflect.TypeOf((*MockStreamI)(nil).AddStreamFrame), arg0)
|
||||
}
|
||||
|
||||
// Cancel mocks base method
|
||||
func (_m *MockStreamI) Cancel(_param0 error) {
|
||||
_m.ctrl.Call(_m, "Cancel", _param0)
|
||||
|
@ -106,6 +94,18 @@ func (_mr *MockStreamIMockRecorder) GetWindowUpdate() *gomock.Call {
|
|||
return _mr.mock.ctrl.RecordCallWithMethodType(_mr.mock, "GetWindowUpdate", reflect.TypeOf((*MockStreamI)(nil).GetWindowUpdate))
|
||||
}
|
||||
|
||||
// HandleStreamFrame mocks base method
|
||||
func (_m *MockStreamI) HandleStreamFrame(_param0 *wire.StreamFrame) error {
|
||||
ret := _m.ctrl.Call(_m, "HandleStreamFrame", _param0)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// HandleStreamFrame indicates an expected call of HandleStreamFrame
|
||||
func (_mr *MockStreamIMockRecorder) HandleStreamFrame(arg0 interface{}) *gomock.Call {
|
||||
return _mr.mock.ctrl.RecordCallWithMethodType(_mr.mock, "HandleStreamFrame", reflect.TypeOf((*MockStreamI)(nil).HandleStreamFrame), arg0)
|
||||
}
|
||||
|
||||
// IsFlowControlBlocked mocks base method
|
||||
func (_m *MockStreamI) IsFlowControlBlocked() bool {
|
||||
ret := _m.ctrl.Call(_m, "IsFlowControlBlocked")
|
||||
|
|
|
@ -566,7 +566,7 @@ func (s *session) handleStreamFrame(frame *wire.StreamFrame) error {
|
|||
if frame.FinBit {
|
||||
return errors.New("Received STREAM frame with FIN bit for the crypto stream")
|
||||
}
|
||||
return s.cryptoStream.AddStreamFrame(frame)
|
||||
return s.cryptoStream.HandleStreamFrame(frame)
|
||||
}
|
||||
str, err := s.streamsMap.GetOrOpenStream(frame.StreamID)
|
||||
if err != nil {
|
||||
|
@ -577,7 +577,7 @@ func (s *session) handleStreamFrame(frame *wire.StreamFrame) error {
|
|||
// ignore this StreamFrame
|
||||
return nil
|
||||
}
|
||||
return str.AddStreamFrame(frame)
|
||||
return str.HandleStreamFrame(frame)
|
||||
}
|
||||
|
||||
func (s *session) handleMaxDataFrame(frame *wire.MaxDataFrame) {
|
||||
|
|
|
@ -283,7 +283,7 @@ var _ = Describe("Session", func() {
|
|||
sess.streamsMap.newStream = func(id protocol.StreamID) streamI {
|
||||
str := newStreamLambda(id)
|
||||
if id == 5 {
|
||||
str.(*mocks.MockStreamI).EXPECT().AddStreamFrame(f)
|
||||
str.(*mocks.MockStreamI).EXPECT().HandleStreamFrame(f)
|
||||
}
|
||||
return str
|
||||
}
|
||||
|
@ -308,8 +308,8 @@ var _ = Describe("Session", func() {
|
|||
sess.streamsMap.newStream = func(id protocol.StreamID) streamI {
|
||||
str := newStreamLambda(id)
|
||||
if id == 5 {
|
||||
str.(*mocks.MockStreamI).EXPECT().AddStreamFrame(f1)
|
||||
str.(*mocks.MockStreamI).EXPECT().AddStreamFrame(f2)
|
||||
str.(*mocks.MockStreamI).EXPECT().HandleStreamFrame(f1)
|
||||
str.(*mocks.MockStreamI).EXPECT().HandleStreamFrame(f2)
|
||||
}
|
||||
return str
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ import (
|
|||
type streamI interface {
|
||||
Stream
|
||||
|
||||
AddStreamFrame(*wire.StreamFrame) error
|
||||
HandleStreamFrame(*wire.StreamFrame) error
|
||||
RegisterRemoteError(error, protocol.ByteCount) error
|
||||
PopStreamFrame(maxBytes protocol.ByteCount) *wire.StreamFrame
|
||||
Finished() bool
|
||||
|
@ -327,8 +327,8 @@ func (s *stream) shouldSendReset() bool {
|
|||
return (s.resetLocally.Get() || s.resetRemotely.Get()) && !s.finishedWriteAndSentFin()
|
||||
}
|
||||
|
||||
// AddStreamFrame adds a new stream frame
|
||||
func (s *stream) AddStreamFrame(frame *wire.StreamFrame) error {
|
||||
// HandleStreamFrame adds a new stream frame
|
||||
func (s *stream) HandleStreamFrame(frame *wire.StreamFrame) error {
|
||||
maxOffset := frame.Offset + frame.DataLen()
|
||||
if err := s.flowController.UpdateHighestReceived(maxOffset, frame.FinBit); err != nil {
|
||||
return err
|
||||
|
@ -390,7 +390,7 @@ func (s *stream) SetDeadline(t time.Time) error {
|
|||
|
||||
// CloseRemote makes the stream receive a "virtual" FIN stream frame at a given offset
|
||||
func (s *stream) CloseRemote(offset protocol.ByteCount) {
|
||||
s.AddStreamFrame(&wire.StreamFrame{FinBit: true, Offset: offset})
|
||||
s.HandleStreamFrame(&wire.StreamFrame{FinBit: true, Offset: offset})
|
||||
}
|
||||
|
||||
// Cancel is called by session to indicate that an error occurred
|
||||
|
|
|
@ -81,7 +81,7 @@ var _ = Describe("Stream", func() {
|
|||
Offset: 0,
|
||||
Data: []byte{0xDE, 0xAD, 0xBE, 0xEF},
|
||||
}
|
||||
err := str.AddStreamFrame(&frame)
|
||||
err := str.HandleStreamFrame(&frame)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
b := make([]byte, 4)
|
||||
n, err := strWithTimeout.Read(b)
|
||||
|
@ -98,7 +98,7 @@ var _ = Describe("Stream", func() {
|
|||
Offset: 0,
|
||||
Data: []byte{0xDE, 0xAD, 0xBE, 0xEF},
|
||||
}
|
||||
err := str.AddStreamFrame(&frame)
|
||||
err := str.HandleStreamFrame(&frame)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
b := make([]byte, 2)
|
||||
n, err := strWithTimeout.Read(b)
|
||||
|
@ -123,9 +123,9 @@ var _ = Describe("Stream", func() {
|
|||
Offset: 2,
|
||||
Data: []byte{0xBE, 0xEF},
|
||||
}
|
||||
err := str.AddStreamFrame(&frame1)
|
||||
err := str.HandleStreamFrame(&frame1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
err = str.AddStreamFrame(&frame2)
|
||||
err = str.HandleStreamFrame(&frame2)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
b := make([]byte, 6)
|
||||
n, err := strWithTimeout.Read(b)
|
||||
|
@ -146,9 +146,9 @@ var _ = Describe("Stream", func() {
|
|||
Offset: 2,
|
||||
Data: []byte{0xBE, 0xEF},
|
||||
}
|
||||
err := str.AddStreamFrame(&frame1)
|
||||
err := str.HandleStreamFrame(&frame1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
err = str.AddStreamFrame(&frame2)
|
||||
err = str.HandleStreamFrame(&frame2)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
b := make([]byte, 4)
|
||||
n, err := strWithTimeout.Read(b)
|
||||
|
@ -164,7 +164,7 @@ var _ = Describe("Stream", func() {
|
|||
defer GinkgoRecover()
|
||||
frame := wire.StreamFrame{Data: []byte{0xDE, 0xAD}}
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
err := str.AddStreamFrame(&frame)
|
||||
err := str.HandleStreamFrame(&frame)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
}()
|
||||
b := make([]byte, 2)
|
||||
|
@ -185,9 +185,9 @@ var _ = Describe("Stream", func() {
|
|||
Offset: 0,
|
||||
Data: []byte{0xDE, 0xAD},
|
||||
}
|
||||
err := str.AddStreamFrame(&frame1)
|
||||
err := str.HandleStreamFrame(&frame1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
err = str.AddStreamFrame(&frame2)
|
||||
err = str.HandleStreamFrame(&frame2)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
b := make([]byte, 4)
|
||||
n, err := strWithTimeout.Read(b)
|
||||
|
@ -213,11 +213,11 @@ var _ = Describe("Stream", func() {
|
|||
Offset: 2,
|
||||
Data: []byte{0xBE, 0xEF},
|
||||
}
|
||||
err := str.AddStreamFrame(&frame1)
|
||||
err := str.HandleStreamFrame(&frame1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
err = str.AddStreamFrame(&frame2)
|
||||
err = str.HandleStreamFrame(&frame2)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
err = str.AddStreamFrame(&frame3)
|
||||
err = str.HandleStreamFrame(&frame3)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
b := make([]byte, 4)
|
||||
n, err := strWithTimeout.Read(b)
|
||||
|
@ -239,9 +239,9 @@ var _ = Describe("Stream", func() {
|
|||
Offset: 2,
|
||||
Data: []byte("obar"),
|
||||
}
|
||||
err := str.AddStreamFrame(&frame1)
|
||||
err := str.HandleStreamFrame(&frame1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
err = str.AddStreamFrame(&frame2)
|
||||
err = str.HandleStreamFrame(&frame2)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
b := make([]byte, 6)
|
||||
n, err := strWithTimeout.Read(b)
|
||||
|
@ -257,7 +257,7 @@ var _ = Describe("Stream", func() {
|
|||
Offset: 0,
|
||||
Data: []byte{0xDE, 0xAD, 0xBE, 0xEF},
|
||||
}
|
||||
str.AddStreamFrame(&frame)
|
||||
str.HandleStreamFrame(&frame)
|
||||
b := make([]byte, 4)
|
||||
_, err := strWithTimeout.Read(b)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
@ -273,7 +273,7 @@ var _ = Describe("Stream", func() {
|
|||
It("returns an error when Read is called after the deadline", func() {
|
||||
mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(6), false).AnyTimes()
|
||||
f := &wire.StreamFrame{Data: []byte("foobar")}
|
||||
err := str.AddStreamFrame(f)
|
||||
err := str.HandleStreamFrame(f)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
str.SetReadDeadline(time.Now().Add(-time.Second))
|
||||
b := make([]byte, 6)
|
||||
|
@ -332,7 +332,7 @@ var _ = Describe("Stream", func() {
|
|||
It("sets a read deadline, when SetDeadline is called", func() {
|
||||
mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(6), false).AnyTimes()
|
||||
f := &wire.StreamFrame{Data: []byte("foobar")}
|
||||
err := str.AddStreamFrame(f)
|
||||
err := str.HandleStreamFrame(f)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
str.SetDeadline(time.Now().Add(-time.Second))
|
||||
b := make([]byte, 6)
|
||||
|
@ -352,7 +352,7 @@ var _ = Describe("Stream", func() {
|
|||
Data: []byte{0xDE, 0xAD, 0xBE, 0xEF},
|
||||
FinBit: true,
|
||||
}
|
||||
str.AddStreamFrame(&frame)
|
||||
str.HandleStreamFrame(&frame)
|
||||
b := make([]byte, 4)
|
||||
n, err := strWithTimeout.Read(b)
|
||||
Expect(err).To(MatchError(io.EOF))
|
||||
|
@ -376,9 +376,9 @@ var _ = Describe("Stream", func() {
|
|||
Offset: 0,
|
||||
Data: []byte{0xDE, 0xAD},
|
||||
}
|
||||
err := str.AddStreamFrame(&frame1)
|
||||
err := str.HandleStreamFrame(&frame1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
err = str.AddStreamFrame(&frame2)
|
||||
err = str.HandleStreamFrame(&frame2)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
b := make([]byte, 4)
|
||||
n, err := strWithTimeout.Read(b)
|
||||
|
@ -398,7 +398,7 @@ var _ = Describe("Stream", func() {
|
|||
Data: []byte{0xDE, 0xAD},
|
||||
FinBit: true,
|
||||
}
|
||||
err := str.AddStreamFrame(&frame)
|
||||
err := str.HandleStreamFrame(&frame)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
b := make([]byte, 4)
|
||||
n, err := strWithTimeout.Read(b)
|
||||
|
@ -415,7 +415,7 @@ var _ = Describe("Stream", func() {
|
|||
Data: []byte{},
|
||||
FinBit: true,
|
||||
}
|
||||
err := str.AddStreamFrame(&frame)
|
||||
err := str.HandleStreamFrame(&frame)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
b := make([]byte, 4)
|
||||
n, err := strWithTimeout.Read(b)
|
||||
|
@ -488,7 +488,7 @@ var _ = Describe("Stream", func() {
|
|||
Offset: 0,
|
||||
Data: []byte{0xDE, 0xAD, 0xBE, 0xEF},
|
||||
}
|
||||
str.AddStreamFrame(&frame)
|
||||
str.HandleStreamFrame(&frame)
|
||||
str.RegisterRemoteError(testErr, 10)
|
||||
b := make([]byte, 4)
|
||||
n, err := strWithTimeout.Read(b)
|
||||
|
@ -504,7 +504,7 @@ var _ = Describe("Stream", func() {
|
|||
Offset: 0,
|
||||
Data: []byte{0xDE, 0xAD, 0xBE, 0xEF},
|
||||
}
|
||||
err := str.AddStreamFrame(&frame)
|
||||
err := str.HandleStreamFrame(&frame)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
b := make([]byte, 4)
|
||||
n, err := strWithTimeout.Read(b)
|
||||
|
@ -519,7 +519,7 @@ var _ = Describe("Stream", func() {
|
|||
Offset: 0,
|
||||
Data: []byte{0xDE, 0xAD, 0xBE, 0xEF},
|
||||
}
|
||||
str.AddStreamFrame(&frame)
|
||||
str.HandleStreamFrame(&frame)
|
||||
str.RegisterRemoteError(testErr, 8)
|
||||
b := make([]byte, 10)
|
||||
n, err := strWithTimeout.Read(b)
|
||||
|
@ -536,7 +536,7 @@ var _ = Describe("Stream", func() {
|
|||
Data: []byte{0xDE, 0xAD, 0xBE, 0xEF},
|
||||
FinBit: true,
|
||||
}
|
||||
str.AddStreamFrame(&frame)
|
||||
str.HandleStreamFrame(&frame)
|
||||
str.RegisterRemoteError(testErr, 8)
|
||||
b := make([]byte, 10)
|
||||
n, err := strWithTimeout.Read(b)
|
||||
|
@ -553,7 +553,7 @@ var _ = Describe("Stream", func() {
|
|||
Data: []byte{0xDE, 0xAD, 0xBE, 0xEF},
|
||||
FinBit: true,
|
||||
}
|
||||
str.AddStreamFrame(&frame)
|
||||
str.HandleStreamFrame(&frame)
|
||||
str.RegisterRemoteError(testErr, 4)
|
||||
b := make([]byte, 3)
|
||||
_, err := strWithTimeout.Read(b)
|
||||
|
@ -575,7 +575,7 @@ var _ = Describe("Stream", func() {
|
|||
StreamID: 5,
|
||||
Data: []byte{0xDE, 0xAD, 0xBE, 0xEF},
|
||||
}
|
||||
str.AddStreamFrame(&frame)
|
||||
str.HandleStreamFrame(&frame)
|
||||
str.RegisterRemoteError(testErr, 10)
|
||||
b := make([]byte, 3)
|
||||
_, err := strWithTimeout.Read(b)
|
||||
|
@ -703,7 +703,7 @@ var _ = Describe("Stream", func() {
|
|||
|
||||
It("doesn't allow further reads", func() {
|
||||
mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(6), false)
|
||||
str.AddStreamFrame(&wire.StreamFrame{
|
||||
str.HandleStreamFrame(&wire.StreamFrame{
|
||||
Data: []byte("foobar"),
|
||||
})
|
||||
str.Reset(testErr)
|
||||
|
@ -994,7 +994,7 @@ var _ = Describe("Stream", func() {
|
|||
Offset: 2,
|
||||
Data: []byte("foobar"),
|
||||
}
|
||||
err := str.AddStreamFrame(&frame)
|
||||
err := str.HandleStreamFrame(&frame)
|
||||
Expect(err).To(MatchError(testErr))
|
||||
})
|
||||
|
||||
|
@ -1003,7 +1003,7 @@ var _ = Describe("Stream", func() {
|
|||
|
||||
finishReading := func() {
|
||||
mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(0), true)
|
||||
err := str.AddStreamFrame(&wire.StreamFrame{FinBit: true})
|
||||
err := str.HandleStreamFrame(&wire.StreamFrame{FinBit: true})
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
b := make([]byte, 100)
|
||||
_, err = strWithTimeout.Read(b)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue