From 022189dfda39dc87eb9481d3e68a4e01463267b7 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Sun, 4 Nov 2018 12:26:02 +0700 Subject: [PATCH] rename the RST_STREAM frame to RESET_STREAM frame --- internal/ackhandler/retransmittable_test.go | 2 +- internal/flowcontrol/interface.go | 2 +- internal/wire/frame_parser.go | 2 +- internal/wire/frame_parser_test.go | 4 ++-- internal/wire/log_test.go | 10 ++++----- ..._stream_frame.go => reset_stream_frame.go} | 14 +++++------- ...ame_test.go => reset_stream_frame_test.go} | 12 +++++----- mock_receive_stream_internal_test.go | 12 +++++----- mock_stream_internal_test.go | 12 +++++----- packet_packer_test.go | 2 +- receive_stream.go | 16 +++++++------- receive_stream_test.go | 22 +++++++++---------- send_stream.go | 2 +- send_stream_test.go | 8 +++---- session.go | 8 +++---- session_test.go | 18 +++++++-------- stream.go | 6 ++--- 17 files changed, 75 insertions(+), 77 deletions(-) rename internal/wire/{rst_stream_frame.go => reset_stream_frame.go} (71%) rename internal/wire/{rst_stream_frame_test.go => reset_stream_frame_test.go} (85%) diff --git a/internal/ackhandler/retransmittable_test.go b/internal/ackhandler/retransmittable_test.go index 3659a055..8927c92e 100644 --- a/internal/ackhandler/retransmittable_test.go +++ b/internal/ackhandler/retransmittable_test.go @@ -14,7 +14,7 @@ var _ = Describe("retransmittable frames", func() { &wire.BlockedFrame{}: true, &wire.ConnectionCloseFrame{}: true, &wire.PingFrame{}: true, - &wire.RstStreamFrame{}: true, + &wire.ResetStreamFrame{}: true, &wire.StreamFrame{}: true, &wire.MaxDataFrame{}: true, &wire.MaxStreamDataFrame{}: true, diff --git a/internal/flowcontrol/interface.go b/internal/flowcontrol/interface.go index 5ee53e52..9f07c887 100644 --- a/internal/flowcontrol/interface.go +++ b/internal/flowcontrol/interface.go @@ -19,7 +19,7 @@ type StreamFlowController interface { flowController // for receiving // 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 } diff --git a/internal/wire/frame_parser.go b/internal/wire/frame_parser.go index 6165f5db..449b6c47 100644 --- a/internal/wire/frame_parser.go +++ b/internal/wire/frame_parser.go @@ -36,7 +36,7 @@ func parseFrame(r *bytes.Reader, typeByte byte, v protocol.VersionNumber) (Frame // TODO: implement all IETF QUIC frame types switch typeByte { case 0x1: - frame, err = parseRstStreamFrame(r, v) + frame, err = parseResetStreamFrame(r, v) if err != nil { err = qerr.Error(qerr.InvalidRstStreamData, err.Error()) } diff --git a/internal/wire/frame_parser_test.go b/internal/wire/frame_parser_test.go index 768d0c16..153db21b 100644 --- a/internal/wire/frame_parser_test.go +++ b/internal/wire/frame_parser_test.go @@ -38,8 +38,8 @@ var _ = Describe("Frame parsing", func() { Expect(r.Len()).To(BeZero()) }) - It("unpacks RST_STREAM frames", func() { - f := &RstStreamFrame{ + It("unpacks RESET_STREAM frames", func() { + f := &ResetStreamFrame{ StreamID: 0xdeadbeef, ByteOffset: 0xdecafbad1234, ErrorCode: 0x1337, diff --git a/internal/wire/log_test.go b/internal/wire/log_test.go index 76eb5bd0..40c8eb94 100644 --- a/internal/wire/log_test.go +++ b/internal/wire/log_test.go @@ -31,18 +31,18 @@ var _ = Describe("Frame logging", func() { It("doesn't log when debug is disabled", func() { logger.SetLogLevel(utils.LogLevelInfo) - LogFrame(logger, &RstStreamFrame{}, true) + LogFrame(logger, &ResetStreamFrame{}, true) Expect(buf.Len()).To(BeZero()) }) It("logs sent frames", func() { - LogFrame(logger, &RstStreamFrame{}, true) - Expect(buf.Bytes()).To(ContainSubstring("\t-> &wire.RstStreamFrame{StreamID:0x0, ErrorCode:0x0, ByteOffset:0x0}\n")) + LogFrame(logger, &ResetStreamFrame{}, true) + Expect(buf.Bytes()).To(ContainSubstring("\t-> &wire.ResetStreamFrame{StreamID:0x0, ErrorCode:0x0, ByteOffset:0x0}\n")) }) It("logs received frames", func() { - LogFrame(logger, &RstStreamFrame{}, false) - Expect(buf.Bytes()).To(ContainSubstring("\t<- &wire.RstStreamFrame{StreamID:0x0, ErrorCode:0x0, ByteOffset:0x0}\n")) + LogFrame(logger, &ResetStreamFrame{}, false) + Expect(buf.Bytes()).To(ContainSubstring("\t<- &wire.ResetStreamFrame{StreamID:0x0, ErrorCode:0x0, ByteOffset:0x0}\n")) }) It("logs CRYPTO frames", func() { diff --git a/internal/wire/rst_stream_frame.go b/internal/wire/reset_stream_frame.go similarity index 71% rename from internal/wire/rst_stream_frame.go rename to internal/wire/reset_stream_frame.go index da47b9f3..7b4373fe 100644 --- a/internal/wire/rst_stream_frame.go +++ b/internal/wire/reset_stream_frame.go @@ -7,15 +7,14 @@ import ( "github.com/lucas-clemente/quic-go/internal/utils" ) -// A RstStreamFrame is a RST_STREAM frame in QUIC -type RstStreamFrame struct { +// A ResetStreamFrame is a RESET_STREAM frame in QUIC +type ResetStreamFrame struct { StreamID protocol.StreamID ErrorCode protocol.ApplicationErrorCode ByteOffset protocol.ByteCount } -// parseRstStreamFrame parses a RST_STREAM frame -func parseRstStreamFrame(r *bytes.Reader, version protocol.VersionNumber) (*RstStreamFrame, error) { +func parseResetStreamFrame(r *bytes.Reader, version protocol.VersionNumber) (*ResetStreamFrame, error) { if _, err := r.ReadByte(); err != nil { // read the TypeByte return nil, err } @@ -38,15 +37,14 @@ func parseRstStreamFrame(r *bytes.Reader, version protocol.VersionNumber) (*RstS } byteOffset = protocol.ByteCount(bo) - return &RstStreamFrame{ + return &ResetStreamFrame{ StreamID: streamID, ErrorCode: protocol.ApplicationErrorCode(errorCode), ByteOffset: byteOffset, }, nil } -//Write writes a RST_STREAM frame -func (f *RstStreamFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error { +func (f *ResetStreamFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error { b.WriteByte(0x01) utils.WriteVarInt(b, uint64(f.StreamID)) 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 -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)) } diff --git a/internal/wire/rst_stream_frame_test.go b/internal/wire/reset_stream_frame_test.go similarity index 85% rename from internal/wire/rst_stream_frame_test.go rename to internal/wire/reset_stream_frame_test.go index 68ac074e..a09ecc29 100644 --- a/internal/wire/rst_stream_frame_test.go +++ b/internal/wire/reset_stream_frame_test.go @@ -9,7 +9,7 @@ import ( . "github.com/onsi/gomega" ) -var _ = Describe("RST_STREAM frame", func() { +var _ = Describe("RESET_STREAM frame", func() { Context("when parsing", func() { It("accepts sample frame", func() { data := []byte{0x1} @@ -17,7 +17,7 @@ var _ = Describe("RST_STREAM frame", func() { data = append(data, []byte{0x13, 0x37}...) // error code data = append(data, encodeVarInt(0x987654321)...) // byte offset b := bytes.NewReader(data) - frame, err := parseRstStreamFrame(b, versionIETFFrames) + frame, err := parseResetStreamFrame(b, versionIETFFrames) Expect(err).ToNot(HaveOccurred()) Expect(frame.StreamID).To(Equal(protocol.StreamID(0xdeadbeef))) 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, []byte{0x13, 0x37}...) // error code data = append(data, encodeVarInt(0x987654321)...) // byte offset - _, err := parseRstStreamFrame(bytes.NewReader(data), versionIETFFrames) + _, err := parseResetStreamFrame(bytes.NewReader(data), versionIETFFrames) Expect(err).NotTo(HaveOccurred()) for i := range data { - _, err := parseRstStreamFrame(bytes.NewReader(data[0:i]), versionIETFFrames) + _, err := parseResetStreamFrame(bytes.NewReader(data[0:i]), versionIETFFrames) Expect(err).To(HaveOccurred()) } }) @@ -40,7 +40,7 @@ var _ = Describe("RST_STREAM frame", func() { Context("when writing", func() { It("writes a sample frame", func() { - frame := RstStreamFrame{ + frame := ResetStreamFrame{ StreamID: 0x1337, ByteOffset: 0x11223344decafbad, ErrorCode: 0xcafe, @@ -56,7 +56,7 @@ var _ = Describe("RST_STREAM frame", func() { }) It("has the correct min length", func() { - rst := RstStreamFrame{ + rst := ResetStreamFrame{ StreamID: 0x1337, ByteOffset: 0x1234567, ErrorCode: 0xde, diff --git a/mock_receive_stream_internal_test.go b/mock_receive_stream_internal_test.go index c41bfa7e..cfe02b55 100644 --- a/mock_receive_stream_internal_test.go +++ b/mock_receive_stream_internal_test.go @@ -107,16 +107,16 @@ func (mr *MockReceiveStreamIMockRecorder) getWindowUpdate() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "getWindowUpdate", reflect.TypeOf((*MockReceiveStreamI)(nil).getWindowUpdate)) } -// handleRstStreamFrame mocks base method -func (m *MockReceiveStreamI) handleRstStreamFrame(arg0 *wire.RstStreamFrame) error { - ret := m.ctrl.Call(m, "handleRstStreamFrame", arg0) +// handleResetStreamFrame mocks base method +func (m *MockReceiveStreamI) handleResetStreamFrame(arg0 *wire.ResetStreamFrame) error { + ret := m.ctrl.Call(m, "handleResetStreamFrame", arg0) ret0, _ := ret[0].(error) return ret0 } -// handleRstStreamFrame indicates an expected call of handleRstStreamFrame -func (mr *MockReceiveStreamIMockRecorder) handleRstStreamFrame(arg0 interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "handleRstStreamFrame", reflect.TypeOf((*MockReceiveStreamI)(nil).handleRstStreamFrame), arg0) +// handleResetStreamFrame indicates an expected call of handleResetStreamFrame +func (mr *MockReceiveStreamIMockRecorder) handleResetStreamFrame(arg0 interface{}) *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "handleResetStreamFrame", reflect.TypeOf((*MockReceiveStreamI)(nil).handleResetStreamFrame), arg0) } // handleStreamFrame mocks base method diff --git a/mock_stream_internal_test.go b/mock_stream_internal_test.go index 59235a68..c3c69fd5 100644 --- a/mock_stream_internal_test.go +++ b/mock_stream_internal_test.go @@ -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) } -// handleRstStreamFrame mocks base method -func (m *MockStreamI) handleRstStreamFrame(arg0 *wire.RstStreamFrame) error { - ret := m.ctrl.Call(m, "handleRstStreamFrame", arg0) +// handleResetStreamFrame mocks base method +func (m *MockStreamI) handleResetStreamFrame(arg0 *wire.ResetStreamFrame) error { + ret := m.ctrl.Call(m, "handleResetStreamFrame", arg0) ret0, _ := ret[0].(error) return ret0 } -// handleRstStreamFrame indicates an expected call of handleRstStreamFrame -func (mr *MockStreamIMockRecorder) handleRstStreamFrame(arg0 interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "handleRstStreamFrame", reflect.TypeOf((*MockStreamI)(nil).handleRstStreamFrame), arg0) +// handleResetStreamFrame indicates an expected call of handleResetStreamFrame +func (mr *MockStreamIMockRecorder) handleResetStreamFrame(arg0 interface{}) *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "handleResetStreamFrame", reflect.TypeOf((*MockStreamI)(nil).handleResetStreamFrame), arg0) } // handleStopSendingFrame mocks base method diff --git a/packet_packer_test.go b/packet_packer_test.go index 6e018ba0..522f5e86 100644 --- a/packet_packer_test.go +++ b/packet_packer_test.go @@ -243,7 +243,7 @@ var _ = Describe("Packet packer", func() { pnManager.EXPECT().PopPacketNumber().Return(protocol.PacketNumber(0x42)) sealingManager.EXPECT().GetSealer().Return(protocol.Encryption1RTT, sealer) ackFramer.EXPECT().GetAckFrame() - frames := []wire.Frame{&wire.RstStreamFrame{}, &wire.MaxDataFrame{}} + frames := []wire.Frame{&wire.ResetStreamFrame{}, &wire.MaxDataFrame{}} expectAppendControlFrames(frames...) expectAppendStreamFrames() p, err := packer.PackPacket() diff --git a/receive_stream.go b/receive_stream.go index 88833bf7..13674e8a 100644 --- a/receive_stream.go +++ b/receive_stream.go @@ -15,7 +15,7 @@ type receiveStreamI interface { ReceiveStream handleStreamFrame(*wire.StreamFrame) error - handleRstStreamFrame(*wire.RstStreamFrame) error + handleResetStreamFrame(*wire.ResetStreamFrame) error closeForShutdown(error) getWindowUpdate() protocol.ByteCount } @@ -41,7 +41,7 @@ type receiveStream struct { closedForShutdown bool // set when CloseForShutdown() is called finRead bool // set once we read a frame with a FinBit canceledRead bool // set when CancelRead() is called - resetRemotely bool // set when HandleRstStreamFrame() is called + resetRemotely bool // set when HandleResetStreamFrame() is called readChan chan struct{} deadline time.Time @@ -159,7 +159,7 @@ func (s *receiveStream) readImpl(p []byte) (bool /*stream completed */, int, err s.readOffset += protocol.ByteCount(m) 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 { s.flowController.AddBytesRead(protocol.ByteCount(m)) } @@ -214,15 +214,15 @@ func (s *receiveStream) handleStreamFrame(frame *wire.StreamFrame) error { return nil } -func (s *receiveStream) handleRstStreamFrame(frame *wire.RstStreamFrame) error { - completed, err := s.handleRstStreamFrameImpl(frame) +func (s *receiveStream) handleResetStreamFrame(frame *wire.ResetStreamFrame) error { + completed, err := s.handleResetStreamFrameImpl(frame) if completed { s.sender.onStreamCompleted(s.streamID) } 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() defer s.mutex.Unlock() @@ -233,7 +233,7 @@ func (s *receiveStream) handleRstStreamFrameImpl(frame *wire.RstStreamFrame) (bo 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 { return false, nil } @@ -273,7 +273,7 @@ func (s *receiveStream) SetReadDeadline(t time.Time) error { // CloseForShutdown closes a stream abruptly. // 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) { s.mutex.Lock() s.closedForShutdown = true diff --git a/receive_stream_test.go b/receive_stream_test.go index 55afdaa4..27543143 100644 --- a/receive_stream_test.go +++ b/receive_stream_test.go @@ -467,7 +467,7 @@ var _ = Describe("Receive Stream", func() { 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().AddBytesRead(protocol.ByteCount(6)) mockFC.EXPECT().MaybeQueueWindowUpdate() @@ -495,8 +495,8 @@ var _ = Describe("Receive Stream", func() { }) }) - Context("receiving RST_STREAM frames", func() { - rst := &wire.RstStreamFrame{ + Context("receiving RESET_STREAM frames", func() { + rst := &wire.ResetStreamFrame{ StreamID: streamID, ByteOffset: 42, ErrorCode: 1234, @@ -516,14 +516,14 @@ var _ = Describe("Receive Stream", func() { }() Consistently(done).ShouldNot(BeClosed()) mockSender.EXPECT().onStreamCompleted(streamID) - str.handleRstStreamFrame(rst) + str.handleResetStreamFrame(rst) Eventually(done).Should(BeClosed()) }) It("doesn't allow further calls to Read", func() { mockSender.EXPECT().onStreamCompleted(streamID) mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(42), true) - err := str.handleRstStreamFrame(rst) + err := str.handleResetStreamFrame(rst) Expect(err).ToNot(HaveOccurred()) _, err = strWithTimeout.Read([]byte{0}) 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))) }) - 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") mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(42), true).Return(testErr) - err := str.handleRstStreamFrame(rst) + err := str.handleResetStreamFrame(rst) Expect(err).To(MatchError(testErr)) }) - It("ignores duplicate RST_STREAM frames", func() { + It("ignores duplicate RESET_STREAM frames", func() { mockSender.EXPECT().onStreamCompleted(streamID) mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(42), true).Times(2) - err := str.handleRstStreamFrame(rst) + err := str.handleResetStreamFrame(rst) Expect(err).ToNot(HaveOccurred()) - err = str.handleRstStreamFrame(rst) + err = str.handleResetStreamFrame(rst) Expect(err).ToNot(HaveOccurred()) }) It("doesn't do anyting when it was closed for shutdown", func() { str.closeForShutdown(nil) - err := str.handleRstStreamFrame(rst) + err := str.handleResetStreamFrame(rst) Expect(err).ToNot(HaveOccurred()) }) }) diff --git a/send_stream.go b/send_stream.go index 6f5b3565..fc96fcc7 100644 --- a/send_stream.go +++ b/send_stream.go @@ -249,7 +249,7 @@ func (s *sendStream) cancelWriteImpl(errorCode protocol.ApplicationErrorCode, wr s.canceledWrite = true s.cancelWriteErr = writeErr s.signalWrite() - s.sender.queueControlFrame(&wire.RstStreamFrame{ + s.sender.queueControlFrame(&wire.ResetStreamFrame{ StreamID: s.streamID, ByteOffset: s.writeOffset, ErrorCode: errorCode, diff --git a/send_stream_test.go b/send_stream_test.go index f6d30437..924f76bc 100644 --- a/send_stream_test.go +++ b/send_stream_test.go @@ -490,8 +490,8 @@ var _ = Describe("Send Stream", func() { Context("stream cancelations", func() { Context("canceling writing", func() { - It("queues a RST_STREAM frame", func() { - mockSender.EXPECT().queueControlFrame(&wire.RstStreamFrame{ + It("queues a RESET_STREAM frame", func() { + mockSender.EXPECT().queueControlFrame(&wire.ResetStreamFrame{ StreamID: streamID, ByteOffset: 1234, ErrorCode: 9876, @@ -562,8 +562,8 @@ var _ = Describe("Send Stream", func() { }) Context("receiving STOP_SENDING frames", func() { - It("queues a RST_STREAM frames with error code Stopping", func() { - mockSender.EXPECT().queueControlFrame(&wire.RstStreamFrame{ + It("queues a RESET_STREAM frames with error code Stopping", func() { + mockSender.EXPECT().queueControlFrame(&wire.ResetStreamFrame{ StreamID: streamID, ErrorCode: errorCodeStopping, }) diff --git a/session.go b/session.go index 46a8222e..b04dd179 100644 --- a/session.go +++ b/session.go @@ -543,8 +543,8 @@ func (s *session) handleFrames(fs []wire.Frame, encLevel protocol.EncryptionLeve err = s.handleAckFrame(frame, encLevel) case *wire.ConnectionCloseFrame: s.closeRemote(qerr.Error(frame.ErrorCode, frame.ReasonPhrase)) - case *wire.RstStreamFrame: - err = s.handleRstStreamFrame(frame) + case *wire.ResetStreamFrame: + err = s.handleResetStreamFrame(frame) case *wire.MaxDataFrame: s.handleMaxDataFrame(frame) case *wire.MaxStreamDataFrame: @@ -631,7 +631,7 @@ func (s *session) handleMaxStreamIDFrame(frame *wire.MaxStreamIDFrame) error { 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) if err != nil { return err @@ -640,7 +640,7 @@ func (s *session) handleRstStreamFrame(frame *wire.RstStreamFrame) error { // stream is closed and already garbage collected return nil } - return str.handleRstStreamFrame(frame) + return str.handleResetStreamFrame(frame) } func (s *session) handleStopSendingFrame(frame *wire.StopSendingFrame) error { diff --git a/session_test.go b/session_test.go index 0a730419..14f8e704 100644 --- a/session_test.go +++ b/session_test.go @@ -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() { - f := &wire.RstStreamFrame{ + f := &wire.ResetStreamFrame{ StreamID: 555, ErrorCode: 42, ByteOffset: 0x1337, } str := NewMockReceiveStreamI(mockCtrl) streamManager.EXPECT().GetOrOpenReceiveStream(protocol.StreamID(555)).Return(str, nil) - str.EXPECT().handleRstStreamFrame(f) - err := sess.handleRstStreamFrame(f) + str.EXPECT().handleResetStreamFrame(f) + err := sess.handleResetStreamFrame(f) Expect(err).ToNot(HaveOccurred()) }) It("returns errors", func() { - f := &wire.RstStreamFrame{ + f := &wire.ResetStreamFrame{ StreamID: 7, ByteOffset: 0x1337, } testErr := errors.New("flow control violation") str := NewMockReceiveStreamI(mockCtrl) streamManager.EXPECT().GetOrOpenReceiveStream(protocol.StreamID(7)).Return(str, nil) - str.EXPECT().handleRstStreamFrame(f).Return(testErr) - err := sess.handleRstStreamFrame(f) + str.EXPECT().handleResetStreamFrame(f).Return(testErr) + err := sess.handleResetStreamFrame(f) 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) - err := sess.handleFrames([]wire.Frame{&wire.RstStreamFrame{ + err := sess.handleFrames([]wire.Frame{&wire.ResetStreamFrame{ StreamID: 3, ErrorCode: 42, }}, protocol.EncryptionUnspecified) diff --git a/stream.go b/stream.go index dffcfa39..dfd0cc6a 100644 --- a/stream.go +++ b/stream.go @@ -46,7 +46,7 @@ type streamI interface { closeForShutdown(error) // for receiving handleStreamFrame(*wire.StreamFrame) error - handleRstStreamFrame(*wire.RstStreamFrame) error + handleResetStreamFrame(*wire.ResetStreamFrame) error getWindowUpdate() protocol.ByteCount // for sending hasData() bool @@ -150,8 +150,8 @@ func (s *stream) closeForShutdown(err error) { s.receiveStream.closeForShutdown(err) } -func (s *stream) handleRstStreamFrame(frame *wire.RstStreamFrame) error { - return s.receiveStream.handleRstStreamFrame(frame) +func (s *stream) handleResetStreamFrame(frame *wire.ResetStreamFrame) error { + return s.receiveStream.handleResetStreamFrame(frame) } // checkIfCompleted is called from the uniStreamSender, when one of the stream halves is completed.