rename the RST_STREAM frame to RESET_STREAM frame

This commit is contained in:
Marten Seemann 2018-11-04 12:26:02 +07:00
parent 7087a16c7f
commit 022189dfda
17 changed files with 75 additions and 77 deletions

View file

@ -14,7 +14,7 @@ var _ = Describe("retransmittable frames", func() {
&wire.BlockedFrame{}: true, &wire.BlockedFrame{}: true,
&wire.ConnectionCloseFrame{}: true, &wire.ConnectionCloseFrame{}: true,
&wire.PingFrame{}: true, &wire.PingFrame{}: true,
&wire.RstStreamFrame{}: true, &wire.ResetStreamFrame{}: true,
&wire.StreamFrame{}: true, &wire.StreamFrame{}: true,
&wire.MaxDataFrame{}: true, &wire.MaxDataFrame{}: true,
&wire.MaxStreamDataFrame{}: true, &wire.MaxStreamDataFrame{}: true,

View file

@ -19,7 +19,7 @@ type StreamFlowController interface {
flowController flowController
// for receiving // for receiving
// UpdateHighestReceived should be called when a new highest offset is received // UpdateHighestReceived should be called when a new highest offset is received
// final has to be to true if this is the final offset of the stream, as contained in a STREAM frame with FIN bit, and the RST_STREAM frame // final has to be to true if this is the final offset of the stream, as contained in a STREAM frame with FIN bit, and the RESET_STREAM frame
UpdateHighestReceived(offset protocol.ByteCount, final bool) error UpdateHighestReceived(offset protocol.ByteCount, final bool) error
} }

View file

@ -36,7 +36,7 @@ func parseFrame(r *bytes.Reader, typeByte byte, v protocol.VersionNumber) (Frame
// TODO: implement all IETF QUIC frame types // TODO: implement all IETF QUIC frame types
switch typeByte { switch typeByte {
case 0x1: case 0x1:
frame, err = parseRstStreamFrame(r, v) frame, err = parseResetStreamFrame(r, v)
if err != nil { if err != nil {
err = qerr.Error(qerr.InvalidRstStreamData, err.Error()) err = qerr.Error(qerr.InvalidRstStreamData, err.Error())
} }

View file

@ -38,8 +38,8 @@ var _ = Describe("Frame parsing", func() {
Expect(r.Len()).To(BeZero()) Expect(r.Len()).To(BeZero())
}) })
It("unpacks RST_STREAM frames", func() { It("unpacks RESET_STREAM frames", func() {
f := &RstStreamFrame{ f := &ResetStreamFrame{
StreamID: 0xdeadbeef, StreamID: 0xdeadbeef,
ByteOffset: 0xdecafbad1234, ByteOffset: 0xdecafbad1234,
ErrorCode: 0x1337, ErrorCode: 0x1337,

View file

@ -31,18 +31,18 @@ var _ = Describe("Frame logging", func() {
It("doesn't log when debug is disabled", func() { It("doesn't log when debug is disabled", func() {
logger.SetLogLevel(utils.LogLevelInfo) logger.SetLogLevel(utils.LogLevelInfo)
LogFrame(logger, &RstStreamFrame{}, true) LogFrame(logger, &ResetStreamFrame{}, true)
Expect(buf.Len()).To(BeZero()) Expect(buf.Len()).To(BeZero())
}) })
It("logs sent frames", func() { It("logs sent frames", func() {
LogFrame(logger, &RstStreamFrame{}, true) LogFrame(logger, &ResetStreamFrame{}, true)
Expect(buf.Bytes()).To(ContainSubstring("\t-> &wire.RstStreamFrame{StreamID:0x0, ErrorCode:0x0, ByteOffset:0x0}\n")) Expect(buf.Bytes()).To(ContainSubstring("\t-> &wire.ResetStreamFrame{StreamID:0x0, ErrorCode:0x0, ByteOffset:0x0}\n"))
}) })
It("logs received frames", func() { It("logs received frames", func() {
LogFrame(logger, &RstStreamFrame{}, false) LogFrame(logger, &ResetStreamFrame{}, false)
Expect(buf.Bytes()).To(ContainSubstring("\t<- &wire.RstStreamFrame{StreamID:0x0, ErrorCode:0x0, ByteOffset:0x0}\n")) Expect(buf.Bytes()).To(ContainSubstring("\t<- &wire.ResetStreamFrame{StreamID:0x0, ErrorCode:0x0, ByteOffset:0x0}\n"))
}) })
It("logs CRYPTO frames", func() { It("logs CRYPTO frames", func() {

View file

@ -7,15 +7,14 @@ import (
"github.com/lucas-clemente/quic-go/internal/utils" "github.com/lucas-clemente/quic-go/internal/utils"
) )
// A RstStreamFrame is a RST_STREAM frame in QUIC // A ResetStreamFrame is a RESET_STREAM frame in QUIC
type RstStreamFrame struct { type ResetStreamFrame struct {
StreamID protocol.StreamID StreamID protocol.StreamID
ErrorCode protocol.ApplicationErrorCode ErrorCode protocol.ApplicationErrorCode
ByteOffset protocol.ByteCount ByteOffset protocol.ByteCount
} }
// parseRstStreamFrame parses a RST_STREAM frame func parseResetStreamFrame(r *bytes.Reader, version protocol.VersionNumber) (*ResetStreamFrame, error) {
func parseRstStreamFrame(r *bytes.Reader, version protocol.VersionNumber) (*RstStreamFrame, error) {
if _, err := r.ReadByte(); err != nil { // read the TypeByte if _, err := r.ReadByte(); err != nil { // read the TypeByte
return nil, err return nil, err
} }
@ -38,15 +37,14 @@ func parseRstStreamFrame(r *bytes.Reader, version protocol.VersionNumber) (*RstS
} }
byteOffset = protocol.ByteCount(bo) byteOffset = protocol.ByteCount(bo)
return &RstStreamFrame{ return &ResetStreamFrame{
StreamID: streamID, StreamID: streamID,
ErrorCode: protocol.ApplicationErrorCode(errorCode), ErrorCode: protocol.ApplicationErrorCode(errorCode),
ByteOffset: byteOffset, ByteOffset: byteOffset,
}, nil }, nil
} }
//Write writes a RST_STREAM frame func (f *ResetStreamFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error {
func (f *RstStreamFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error {
b.WriteByte(0x01) b.WriteByte(0x01)
utils.WriteVarInt(b, uint64(f.StreamID)) utils.WriteVarInt(b, uint64(f.StreamID))
utils.BigEndian.WriteUint16(b, uint16(f.ErrorCode)) utils.BigEndian.WriteUint16(b, uint16(f.ErrorCode))
@ -55,6 +53,6 @@ func (f *RstStreamFrame) Write(b *bytes.Buffer, version protocol.VersionNumber)
} }
// Length of a written frame // Length of a written frame
func (f *RstStreamFrame) Length(version protocol.VersionNumber) protocol.ByteCount { func (f *ResetStreamFrame) Length(version protocol.VersionNumber) protocol.ByteCount {
return 1 + utils.VarIntLen(uint64(f.StreamID)) + 2 + utils.VarIntLen(uint64(f.ByteOffset)) return 1 + utils.VarIntLen(uint64(f.StreamID)) + 2 + utils.VarIntLen(uint64(f.ByteOffset))
} }

View file

@ -9,7 +9,7 @@ import (
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )
var _ = Describe("RST_STREAM frame", func() { var _ = Describe("RESET_STREAM frame", func() {
Context("when parsing", func() { Context("when parsing", func() {
It("accepts sample frame", func() { It("accepts sample frame", func() {
data := []byte{0x1} data := []byte{0x1}
@ -17,7 +17,7 @@ var _ = Describe("RST_STREAM frame", func() {
data = append(data, []byte{0x13, 0x37}...) // error code data = append(data, []byte{0x13, 0x37}...) // error code
data = append(data, encodeVarInt(0x987654321)...) // byte offset data = append(data, encodeVarInt(0x987654321)...) // byte offset
b := bytes.NewReader(data) b := bytes.NewReader(data)
frame, err := parseRstStreamFrame(b, versionIETFFrames) frame, err := parseResetStreamFrame(b, versionIETFFrames)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Expect(frame.StreamID).To(Equal(protocol.StreamID(0xdeadbeef))) Expect(frame.StreamID).To(Equal(protocol.StreamID(0xdeadbeef)))
Expect(frame.ByteOffset).To(Equal(protocol.ByteCount(0x987654321))) Expect(frame.ByteOffset).To(Equal(protocol.ByteCount(0x987654321)))
@ -29,10 +29,10 @@ var _ = Describe("RST_STREAM frame", func() {
data = append(data, encodeVarInt(0xdeadbeef)...) // stream ID data = append(data, encodeVarInt(0xdeadbeef)...) // stream ID
data = append(data, []byte{0x13, 0x37}...) // error code data = append(data, []byte{0x13, 0x37}...) // error code
data = append(data, encodeVarInt(0x987654321)...) // byte offset data = append(data, encodeVarInt(0x987654321)...) // byte offset
_, err := parseRstStreamFrame(bytes.NewReader(data), versionIETFFrames) _, err := parseResetStreamFrame(bytes.NewReader(data), versionIETFFrames)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
for i := range data { for i := range data {
_, err := parseRstStreamFrame(bytes.NewReader(data[0:i]), versionIETFFrames) _, err := parseResetStreamFrame(bytes.NewReader(data[0:i]), versionIETFFrames)
Expect(err).To(HaveOccurred()) Expect(err).To(HaveOccurred())
} }
}) })
@ -40,7 +40,7 @@ var _ = Describe("RST_STREAM frame", func() {
Context("when writing", func() { Context("when writing", func() {
It("writes a sample frame", func() { It("writes a sample frame", func() {
frame := RstStreamFrame{ frame := ResetStreamFrame{
StreamID: 0x1337, StreamID: 0x1337,
ByteOffset: 0x11223344decafbad, ByteOffset: 0x11223344decafbad,
ErrorCode: 0xcafe, ErrorCode: 0xcafe,
@ -56,7 +56,7 @@ var _ = Describe("RST_STREAM frame", func() {
}) })
It("has the correct min length", func() { It("has the correct min length", func() {
rst := RstStreamFrame{ rst := ResetStreamFrame{
StreamID: 0x1337, StreamID: 0x1337,
ByteOffset: 0x1234567, ByteOffset: 0x1234567,
ErrorCode: 0xde, ErrorCode: 0xde,

View file

@ -107,16 +107,16 @@ func (mr *MockReceiveStreamIMockRecorder) getWindowUpdate() *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "getWindowUpdate", reflect.TypeOf((*MockReceiveStreamI)(nil).getWindowUpdate)) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "getWindowUpdate", reflect.TypeOf((*MockReceiveStreamI)(nil).getWindowUpdate))
} }
// handleRstStreamFrame mocks base method // handleResetStreamFrame mocks base method
func (m *MockReceiveStreamI) handleRstStreamFrame(arg0 *wire.RstStreamFrame) error { func (m *MockReceiveStreamI) handleResetStreamFrame(arg0 *wire.ResetStreamFrame) error {
ret := m.ctrl.Call(m, "handleRstStreamFrame", arg0) ret := m.ctrl.Call(m, "handleResetStreamFrame", arg0)
ret0, _ := ret[0].(error) ret0, _ := ret[0].(error)
return ret0 return ret0
} }
// handleRstStreamFrame indicates an expected call of handleRstStreamFrame // handleResetStreamFrame indicates an expected call of handleResetStreamFrame
func (mr *MockReceiveStreamIMockRecorder) handleRstStreamFrame(arg0 interface{}) *gomock.Call { func (mr *MockReceiveStreamIMockRecorder) handleResetStreamFrame(arg0 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "handleRstStreamFrame", reflect.TypeOf((*MockReceiveStreamI)(nil).handleRstStreamFrame), arg0) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "handleResetStreamFrame", reflect.TypeOf((*MockReceiveStreamI)(nil).handleResetStreamFrame), arg0)
} }
// handleStreamFrame mocks base method // handleStreamFrame mocks base method

View file

@ -191,16 +191,16 @@ func (mr *MockStreamIMockRecorder) handleMaxStreamDataFrame(arg0 interface{}) *g
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "handleMaxStreamDataFrame", reflect.TypeOf((*MockStreamI)(nil).handleMaxStreamDataFrame), arg0) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "handleMaxStreamDataFrame", reflect.TypeOf((*MockStreamI)(nil).handleMaxStreamDataFrame), arg0)
} }
// handleRstStreamFrame mocks base method // handleResetStreamFrame mocks base method
func (m *MockStreamI) handleRstStreamFrame(arg0 *wire.RstStreamFrame) error { func (m *MockStreamI) handleResetStreamFrame(arg0 *wire.ResetStreamFrame) error {
ret := m.ctrl.Call(m, "handleRstStreamFrame", arg0) ret := m.ctrl.Call(m, "handleResetStreamFrame", arg0)
ret0, _ := ret[0].(error) ret0, _ := ret[0].(error)
return ret0 return ret0
} }
// handleRstStreamFrame indicates an expected call of handleRstStreamFrame // handleResetStreamFrame indicates an expected call of handleResetStreamFrame
func (mr *MockStreamIMockRecorder) handleRstStreamFrame(arg0 interface{}) *gomock.Call { func (mr *MockStreamIMockRecorder) handleResetStreamFrame(arg0 interface{}) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "handleRstStreamFrame", reflect.TypeOf((*MockStreamI)(nil).handleRstStreamFrame), arg0) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "handleResetStreamFrame", reflect.TypeOf((*MockStreamI)(nil).handleResetStreamFrame), arg0)
} }
// handleStopSendingFrame mocks base method // handleStopSendingFrame mocks base method

View file

@ -243,7 +243,7 @@ var _ = Describe("Packet packer", func() {
pnManager.EXPECT().PopPacketNumber().Return(protocol.PacketNumber(0x42)) pnManager.EXPECT().PopPacketNumber().Return(protocol.PacketNumber(0x42))
sealingManager.EXPECT().GetSealer().Return(protocol.Encryption1RTT, sealer) sealingManager.EXPECT().GetSealer().Return(protocol.Encryption1RTT, sealer)
ackFramer.EXPECT().GetAckFrame() ackFramer.EXPECT().GetAckFrame()
frames := []wire.Frame{&wire.RstStreamFrame{}, &wire.MaxDataFrame{}} frames := []wire.Frame{&wire.ResetStreamFrame{}, &wire.MaxDataFrame{}}
expectAppendControlFrames(frames...) expectAppendControlFrames(frames...)
expectAppendStreamFrames() expectAppendStreamFrames()
p, err := packer.PackPacket() p, err := packer.PackPacket()

View file

@ -15,7 +15,7 @@ type receiveStreamI interface {
ReceiveStream ReceiveStream
handleStreamFrame(*wire.StreamFrame) error handleStreamFrame(*wire.StreamFrame) error
handleRstStreamFrame(*wire.RstStreamFrame) error handleResetStreamFrame(*wire.ResetStreamFrame) error
closeForShutdown(error) closeForShutdown(error)
getWindowUpdate() protocol.ByteCount getWindowUpdate() protocol.ByteCount
} }
@ -41,7 +41,7 @@ type receiveStream struct {
closedForShutdown bool // set when CloseForShutdown() is called closedForShutdown bool // set when CloseForShutdown() is called
finRead bool // set once we read a frame with a FinBit finRead bool // set once we read a frame with a FinBit
canceledRead bool // set when CancelRead() is called canceledRead bool // set when CancelRead() is called
resetRemotely bool // set when HandleRstStreamFrame() is called resetRemotely bool // set when HandleResetStreamFrame() is called
readChan chan struct{} readChan chan struct{}
deadline time.Time deadline time.Time
@ -159,7 +159,7 @@ func (s *receiveStream) readImpl(p []byte) (bool /*stream completed */, int, err
s.readOffset += protocol.ByteCount(m) s.readOffset += protocol.ByteCount(m)
s.mutex.Lock() s.mutex.Lock()
// when a RST_STREAM was received, the was already informed about the final byteOffset for this stream // when a RESET_STREAM was received, the was already informed about the final byteOffset for this stream
if !s.resetRemotely { if !s.resetRemotely {
s.flowController.AddBytesRead(protocol.ByteCount(m)) s.flowController.AddBytesRead(protocol.ByteCount(m))
} }
@ -214,15 +214,15 @@ func (s *receiveStream) handleStreamFrame(frame *wire.StreamFrame) error {
return nil return nil
} }
func (s *receiveStream) handleRstStreamFrame(frame *wire.RstStreamFrame) error { func (s *receiveStream) handleResetStreamFrame(frame *wire.ResetStreamFrame) error {
completed, err := s.handleRstStreamFrameImpl(frame) completed, err := s.handleResetStreamFrameImpl(frame)
if completed { if completed {
s.sender.onStreamCompleted(s.streamID) s.sender.onStreamCompleted(s.streamID)
} }
return err return err
} }
func (s *receiveStream) handleRstStreamFrameImpl(frame *wire.RstStreamFrame) (bool /*completed */, error) { func (s *receiveStream) handleResetStreamFrameImpl(frame *wire.ResetStreamFrame) (bool /*completed */, error) {
s.mutex.Lock() s.mutex.Lock()
defer s.mutex.Unlock() defer s.mutex.Unlock()
@ -233,7 +233,7 @@ func (s *receiveStream) handleRstStreamFrameImpl(frame *wire.RstStreamFrame) (bo
return false, err return false, err
} }
// ignore duplicate RST_STREAM frames for this stream (after checking their final offset) // ignore duplicate RESET_STREAM frames for this stream (after checking their final offset)
if s.resetRemotely { if s.resetRemotely {
return false, nil return false, nil
} }
@ -273,7 +273,7 @@ func (s *receiveStream) SetReadDeadline(t time.Time) error {
// CloseForShutdown closes a stream abruptly. // CloseForShutdown closes a stream abruptly.
// It makes Read unblock (and return the error) immediately. // It makes Read unblock (and return the error) immediately.
// The peer will NOT be informed about this: the stream is closed without sending a FIN or RST. // The peer will NOT be informed about this: the stream is closed without sending a FIN or RESET.
func (s *receiveStream) closeForShutdown(err error) { func (s *receiveStream) closeForShutdown(err error) {
s.mutex.Lock() s.mutex.Lock()
s.closedForShutdown = true s.closedForShutdown = true

View file

@ -467,7 +467,7 @@ var _ = Describe("Receive Stream", func() {
Expect(err).To(MatchError("Read on stream 1337 canceled with error code 1234")) Expect(err).To(MatchError("Read on stream 1337 canceled with error code 1234"))
}) })
It("doesn't send a RST_STREAM frame, if the FIN was already read", func() { It("doesn't send a RESET_STREAM frame, if the FIN was already read", func() {
mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(6), true) mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(6), true)
mockFC.EXPECT().AddBytesRead(protocol.ByteCount(6)) mockFC.EXPECT().AddBytesRead(protocol.ByteCount(6))
mockFC.EXPECT().MaybeQueueWindowUpdate() mockFC.EXPECT().MaybeQueueWindowUpdate()
@ -495,8 +495,8 @@ var _ = Describe("Receive Stream", func() {
}) })
}) })
Context("receiving RST_STREAM frames", func() { Context("receiving RESET_STREAM frames", func() {
rst := &wire.RstStreamFrame{ rst := &wire.ResetStreamFrame{
StreamID: streamID, StreamID: streamID,
ByteOffset: 42, ByteOffset: 42,
ErrorCode: 1234, ErrorCode: 1234,
@ -516,14 +516,14 @@ var _ = Describe("Receive Stream", func() {
}() }()
Consistently(done).ShouldNot(BeClosed()) Consistently(done).ShouldNot(BeClosed())
mockSender.EXPECT().onStreamCompleted(streamID) mockSender.EXPECT().onStreamCompleted(streamID)
str.handleRstStreamFrame(rst) str.handleResetStreamFrame(rst)
Eventually(done).Should(BeClosed()) Eventually(done).Should(BeClosed())
}) })
It("doesn't allow further calls to Read", func() { It("doesn't allow further calls to Read", func() {
mockSender.EXPECT().onStreamCompleted(streamID) mockSender.EXPECT().onStreamCompleted(streamID)
mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(42), true) mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(42), true)
err := str.handleRstStreamFrame(rst) err := str.handleResetStreamFrame(rst)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
_, err = strWithTimeout.Read([]byte{0}) _, err = strWithTimeout.Read([]byte{0})
Expect(err).To(MatchError("Stream 1337 was reset with error code 1234")) Expect(err).To(MatchError("Stream 1337 was reset with error code 1234"))
@ -532,25 +532,25 @@ var _ = Describe("Receive Stream", func() {
Expect(err.(streamCanceledError).ErrorCode()).To(Equal(protocol.ApplicationErrorCode(1234))) Expect(err.(streamCanceledError).ErrorCode()).To(Equal(protocol.ApplicationErrorCode(1234)))
}) })
It("errors when receiving a RST_STREAM with an inconsistent offset", func() { It("errors when receiving a RESET_STREAM with an inconsistent offset", func() {
testErr := errors.New("already received a different final offset before") testErr := errors.New("already received a different final offset before")
mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(42), true).Return(testErr) mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(42), true).Return(testErr)
err := str.handleRstStreamFrame(rst) err := str.handleResetStreamFrame(rst)
Expect(err).To(MatchError(testErr)) Expect(err).To(MatchError(testErr))
}) })
It("ignores duplicate RST_STREAM frames", func() { It("ignores duplicate RESET_STREAM frames", func() {
mockSender.EXPECT().onStreamCompleted(streamID) mockSender.EXPECT().onStreamCompleted(streamID)
mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(42), true).Times(2) mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(42), true).Times(2)
err := str.handleRstStreamFrame(rst) err := str.handleResetStreamFrame(rst)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
err = str.handleRstStreamFrame(rst) err = str.handleResetStreamFrame(rst)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
It("doesn't do anyting when it was closed for shutdown", func() { It("doesn't do anyting when it was closed for shutdown", func() {
str.closeForShutdown(nil) str.closeForShutdown(nil)
err := str.handleRstStreamFrame(rst) err := str.handleResetStreamFrame(rst)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
}) })

View file

@ -249,7 +249,7 @@ func (s *sendStream) cancelWriteImpl(errorCode protocol.ApplicationErrorCode, wr
s.canceledWrite = true s.canceledWrite = true
s.cancelWriteErr = writeErr s.cancelWriteErr = writeErr
s.signalWrite() s.signalWrite()
s.sender.queueControlFrame(&wire.RstStreamFrame{ s.sender.queueControlFrame(&wire.ResetStreamFrame{
StreamID: s.streamID, StreamID: s.streamID,
ByteOffset: s.writeOffset, ByteOffset: s.writeOffset,
ErrorCode: errorCode, ErrorCode: errorCode,

View file

@ -490,8 +490,8 @@ var _ = Describe("Send Stream", func() {
Context("stream cancelations", func() { Context("stream cancelations", func() {
Context("canceling writing", func() { Context("canceling writing", func() {
It("queues a RST_STREAM frame", func() { It("queues a RESET_STREAM frame", func() {
mockSender.EXPECT().queueControlFrame(&wire.RstStreamFrame{ mockSender.EXPECT().queueControlFrame(&wire.ResetStreamFrame{
StreamID: streamID, StreamID: streamID,
ByteOffset: 1234, ByteOffset: 1234,
ErrorCode: 9876, ErrorCode: 9876,
@ -562,8 +562,8 @@ var _ = Describe("Send Stream", func() {
}) })
Context("receiving STOP_SENDING frames", func() { Context("receiving STOP_SENDING frames", func() {
It("queues a RST_STREAM frames with error code Stopping", func() { It("queues a RESET_STREAM frames with error code Stopping", func() {
mockSender.EXPECT().queueControlFrame(&wire.RstStreamFrame{ mockSender.EXPECT().queueControlFrame(&wire.ResetStreamFrame{
StreamID: streamID, StreamID: streamID,
ErrorCode: errorCodeStopping, ErrorCode: errorCodeStopping,
}) })

View file

@ -543,8 +543,8 @@ func (s *session) handleFrames(fs []wire.Frame, encLevel protocol.EncryptionLeve
err = s.handleAckFrame(frame, encLevel) err = s.handleAckFrame(frame, encLevel)
case *wire.ConnectionCloseFrame: case *wire.ConnectionCloseFrame:
s.closeRemote(qerr.Error(frame.ErrorCode, frame.ReasonPhrase)) s.closeRemote(qerr.Error(frame.ErrorCode, frame.ReasonPhrase))
case *wire.RstStreamFrame: case *wire.ResetStreamFrame:
err = s.handleRstStreamFrame(frame) err = s.handleResetStreamFrame(frame)
case *wire.MaxDataFrame: case *wire.MaxDataFrame:
s.handleMaxDataFrame(frame) s.handleMaxDataFrame(frame)
case *wire.MaxStreamDataFrame: case *wire.MaxStreamDataFrame:
@ -631,7 +631,7 @@ func (s *session) handleMaxStreamIDFrame(frame *wire.MaxStreamIDFrame) error {
return s.streamsMap.HandleMaxStreamIDFrame(frame) return s.streamsMap.HandleMaxStreamIDFrame(frame)
} }
func (s *session) handleRstStreamFrame(frame *wire.RstStreamFrame) error { func (s *session) handleResetStreamFrame(frame *wire.ResetStreamFrame) error {
str, err := s.streamsMap.GetOrOpenReceiveStream(frame.StreamID) str, err := s.streamsMap.GetOrOpenReceiveStream(frame.StreamID)
if err != nil { if err != nil {
return err return err
@ -640,7 +640,7 @@ func (s *session) handleRstStreamFrame(frame *wire.RstStreamFrame) error {
// stream is closed and already garbage collected // stream is closed and already garbage collected
return nil return nil
} }
return str.handleRstStreamFrame(frame) return str.handleResetStreamFrame(frame)
} }
func (s *session) handleStopSendingFrame(frame *wire.StopSendingFrame) error { func (s *session) handleStopSendingFrame(frame *wire.StopSendingFrame) error {

View file

@ -174,36 +174,36 @@ var _ = Describe("Session", func() {
}) })
}) })
Context("handling RST_STREAM frames", func() { Context("handling RESET_STREAM frames", func() {
It("closes the streams for writing", func() { It("closes the streams for writing", func() {
f := &wire.RstStreamFrame{ f := &wire.ResetStreamFrame{
StreamID: 555, StreamID: 555,
ErrorCode: 42, ErrorCode: 42,
ByteOffset: 0x1337, ByteOffset: 0x1337,
} }
str := NewMockReceiveStreamI(mockCtrl) str := NewMockReceiveStreamI(mockCtrl)
streamManager.EXPECT().GetOrOpenReceiveStream(protocol.StreamID(555)).Return(str, nil) streamManager.EXPECT().GetOrOpenReceiveStream(protocol.StreamID(555)).Return(str, nil)
str.EXPECT().handleRstStreamFrame(f) str.EXPECT().handleResetStreamFrame(f)
err := sess.handleRstStreamFrame(f) err := sess.handleResetStreamFrame(f)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
It("returns errors", func() { It("returns errors", func() {
f := &wire.RstStreamFrame{ f := &wire.ResetStreamFrame{
StreamID: 7, StreamID: 7,
ByteOffset: 0x1337, ByteOffset: 0x1337,
} }
testErr := errors.New("flow control violation") testErr := errors.New("flow control violation")
str := NewMockReceiveStreamI(mockCtrl) str := NewMockReceiveStreamI(mockCtrl)
streamManager.EXPECT().GetOrOpenReceiveStream(protocol.StreamID(7)).Return(str, nil) streamManager.EXPECT().GetOrOpenReceiveStream(protocol.StreamID(7)).Return(str, nil)
str.EXPECT().handleRstStreamFrame(f).Return(testErr) str.EXPECT().handleResetStreamFrame(f).Return(testErr)
err := sess.handleRstStreamFrame(f) err := sess.handleResetStreamFrame(f)
Expect(err).To(MatchError(testErr)) Expect(err).To(MatchError(testErr))
}) })
It("ignores RST_STREAM frames for closed streams", func() { It("ignores RESET_STREAM frames for closed streams", func() {
streamManager.EXPECT().GetOrOpenReceiveStream(protocol.StreamID(3)).Return(nil, nil) streamManager.EXPECT().GetOrOpenReceiveStream(protocol.StreamID(3)).Return(nil, nil)
err := sess.handleFrames([]wire.Frame{&wire.RstStreamFrame{ err := sess.handleFrames([]wire.Frame{&wire.ResetStreamFrame{
StreamID: 3, StreamID: 3,
ErrorCode: 42, ErrorCode: 42,
}}, protocol.EncryptionUnspecified) }}, protocol.EncryptionUnspecified)

View file

@ -46,7 +46,7 @@ type streamI interface {
closeForShutdown(error) closeForShutdown(error)
// for receiving // for receiving
handleStreamFrame(*wire.StreamFrame) error handleStreamFrame(*wire.StreamFrame) error
handleRstStreamFrame(*wire.RstStreamFrame) error handleResetStreamFrame(*wire.ResetStreamFrame) error
getWindowUpdate() protocol.ByteCount getWindowUpdate() protocol.ByteCount
// for sending // for sending
hasData() bool hasData() bool
@ -150,8 +150,8 @@ func (s *stream) closeForShutdown(err error) {
s.receiveStream.closeForShutdown(err) s.receiveStream.closeForShutdown(err)
} }
func (s *stream) handleRstStreamFrame(frame *wire.RstStreamFrame) error { func (s *stream) handleResetStreamFrame(frame *wire.ResetStreamFrame) error {
return s.receiveStream.handleRstStreamFrame(frame) return s.receiveStream.handleResetStreamFrame(frame)
} }
// checkIfCompleted is called from the uniStreamSender, when one of the stream halves is completed. // checkIfCompleted is called from the uniStreamSender, when one of the stream halves is completed.