rename StreamFrame.FinBit to Fin

This commit is contained in:
Marten Seemann 2020-07-02 16:30:32 +07:00
parent 865332015c
commit 838dd6e81a
14 changed files with 64 additions and 64 deletions

View file

@ -70,11 +70,11 @@ func getFrames() []wire.Frame {
frames := []wire.Frame{ frames := []wire.Frame{
&wire.StreamFrame{ // STREAM frame at 0 offset, with FIN bit &wire.StreamFrame{ // STREAM frame at 0 offset, with FIN bit
StreamID: protocol.StreamID(getRandomNumber()), StreamID: protocol.StreamID(getRandomNumber()),
FinBit: true, Fin: true,
}, },
&wire.StreamFrame{ // STREAM frame at 0 offset, with data and FIN bit &wire.StreamFrame{ // STREAM frame at 0 offset, with data and FIN bit
StreamID: protocol.StreamID(getRandomNumber()), StreamID: protocol.StreamID(getRandomNumber()),
FinBit: true, Fin: true,
Data: getRandomData(100), Data: getRandomData(100),
}, },
&wire.StreamFrame{ // STREAM frame at non-zero offset, with data &wire.StreamFrame{ // STREAM frame at non-zero offset, with data
@ -86,19 +86,19 @@ func getFrames() []wire.Frame {
StreamID: protocol.StreamID(getRandomNumber()), StreamID: protocol.StreamID(getRandomNumber()),
Offset: protocol.ByteCount(getRandomNumber()), Offset: protocol.ByteCount(getRandomNumber()),
Data: getRandomData(50), Data: getRandomData(50),
FinBit: true, Fin: true,
}, },
&wire.StreamFrame{ // STREAM frame at non-zero offset, with data and FIN bit. Long enough to use the buffer. &wire.StreamFrame{ // STREAM frame at non-zero offset, with data and FIN bit. Long enough to use the buffer.
StreamID: protocol.StreamID(getRandomNumber()), StreamID: protocol.StreamID(getRandomNumber()),
Offset: protocol.ByteCount(getRandomNumber()), Offset: protocol.ByteCount(getRandomNumber()),
Data: getRandomData(2 * protocol.MinStreamFrameBufferSize), Data: getRandomData(2 * protocol.MinStreamFrameBufferSize),
FinBit: true, Fin: true,
}, },
&wire.StreamFrame{ // STREAM frame at maximum offset, with FIN bit &wire.StreamFrame{ // STREAM frame at maximum offset, with FIN bit
StreamID: protocol.StreamID(getRandomNumber()), StreamID: protocol.StreamID(getRandomNumber()),
Offset: protocol.MaxByteCount - 5, Offset: protocol.MaxByteCount - 5,
Data: getRandomData(5), Data: getRandomData(5),
FinBit: true, Fin: true,
}, },
&wire.StreamFrame{ // STREAM frame with data at maximum offset &wire.StreamFrame{ // STREAM frame with data at maximum offset
StreamID: protocol.StreamID(getRandomNumber()), StreamID: protocol.StreamID(getRandomNumber()),

View file

@ -130,7 +130,7 @@ var _ = Describe("Frame parsing", func() {
f := &StreamFrame{ f := &StreamFrame{
StreamID: 0x42, StreamID: 0x42,
Offset: 0x1337, Offset: 0x1337,
FinBit: true, Fin: true,
Data: []byte("foobar"), Data: []byte("foobar"),
} }
err := f.Write(buf, versionIETFFrames) err := f.Write(buf, versionIETFFrames)

View file

@ -22,7 +22,7 @@ func LogFrame(logger utils.Logger, frame Frame, sent bool) {
dataLen := protocol.ByteCount(len(f.Data)) dataLen := protocol.ByteCount(len(f.Data))
logger.Debugf("\t%s &wire.CryptoFrame{Offset: %d, Data length: %d, Offset + Data length: %d}", dir, f.Offset, dataLen, f.Offset+dataLen) logger.Debugf("\t%s &wire.CryptoFrame{Offset: %d, Data length: %d, Offset + Data length: %d}", dir, f.Offset, dataLen, f.Offset+dataLen)
case *StreamFrame: case *StreamFrame:
logger.Debugf("\t%s &wire.StreamFrame{StreamID: %d, FinBit: %t, Offset: %d, Data length: %d, Offset + Data length: %d}", dir, f.StreamID, f.FinBit, f.Offset, f.DataLen(), f.Offset+f.DataLen()) logger.Debugf("\t%s &wire.StreamFrame{StreamID: %d, Fin: %t, Offset: %d, Data length: %d, Offset + Data length: %d}", dir, f.StreamID, f.Fin, f.Offset, f.DataLen(), f.Offset+f.DataLen())
case *ResetStreamFrame: case *ResetStreamFrame:
logger.Debugf("\t%s &wire.ResetStreamFrame{StreamID: %d, ErrorCode: %#x, FinalSize: %d}", dir, f.StreamID, f.ErrorCode, f.FinalSize) logger.Debugf("\t%s &wire.ResetStreamFrame{StreamID: %d, ErrorCode: %#x, FinalSize: %d}", dir, f.StreamID, f.ErrorCode, f.FinalSize)
case *AckFrame: case *AckFrame:

View file

@ -63,7 +63,7 @@ var _ = Describe("Frame logging", func() {
Data: bytes.Repeat([]byte{'f'}, 100), Data: bytes.Repeat([]byte{'f'}, 100),
} }
LogFrame(logger, frame, false) LogFrame(logger, frame, false)
Expect(buf.String()).To(ContainSubstring("\t<- &wire.StreamFrame{StreamID: 42, FinBit: false, Offset: 1337, Data length: 100, Offset + Data length: 1437}\n")) Expect(buf.String()).To(ContainSubstring("\t<- &wire.StreamFrame{StreamID: 42, Fin: false, Offset: 1337, Data length: 100, Offset + Data length: 1437}\n"))
}) })
It("logs ACK frames without missing packets", func() { It("logs ACK frames without missing packets", func() {

View file

@ -15,7 +15,7 @@ type StreamFrame struct {
StreamID protocol.StreamID StreamID protocol.StreamID
Offset protocol.ByteCount Offset protocol.ByteCount
Data []byte Data []byte
FinBit bool Fin bool
DataLenPresent bool DataLenPresent bool
fromPool bool fromPool bool
@ -70,7 +70,7 @@ func parseStreamFrame(r *bytes.Reader, _ protocol.VersionNumber) (*StreamFrame,
frame.StreamID = protocol.StreamID(streamID) frame.StreamID = protocol.StreamID(streamID)
frame.Offset = protocol.ByteCount(offset) frame.Offset = protocol.ByteCount(offset)
frame.FinBit = fin frame.Fin = fin
frame.DataLenPresent = hasDataLen frame.DataLenPresent = hasDataLen
if dataLen != 0 { if dataLen != 0 {
@ -86,12 +86,12 @@ func parseStreamFrame(r *bytes.Reader, _ protocol.VersionNumber) (*StreamFrame,
// Write writes a STREAM frame // Write writes a STREAM frame
func (f *StreamFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error { func (f *StreamFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error {
if len(f.Data) == 0 && !f.FinBit { if len(f.Data) == 0 && !f.Fin {
return errors.New("StreamFrame: attempting to write empty frame without FIN") return errors.New("StreamFrame: attempting to write empty frame without FIN")
} }
typeByte := byte(0x8) typeByte := byte(0x8)
if f.FinBit { if f.Fin {
typeByte ^= 0x1 typeByte ^= 0x1
} }
hasOffset := f.Offset != 0 hasOffset := f.Offset != 0
@ -170,7 +170,7 @@ func (f *StreamFrame) MaybeSplitOffFrame(maxSize protocol.ByteCount, version pro
new := GetStreamFrame() new := GetStreamFrame()
new.StreamID = f.StreamID new.StreamID = f.StreamID
new.Offset = f.Offset new.Offset = f.Offset
new.FinBit = false new.Fin = false
new.DataLenPresent = f.DataLenPresent new.DataLenPresent = f.DataLenPresent
// swap the data slices // swap the data slices

View file

@ -22,7 +22,7 @@ var _ = Describe("STREAM frame", func() {
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Expect(frame.StreamID).To(Equal(protocol.StreamID(0x12345))) Expect(frame.StreamID).To(Equal(protocol.StreamID(0x12345)))
Expect(frame.Data).To(Equal([]byte("foobar"))) Expect(frame.Data).To(Equal([]byte("foobar")))
Expect(frame.FinBit).To(BeFalse()) Expect(frame.Fin).To(BeFalse())
Expect(frame.Offset).To(Equal(protocol.ByteCount(0xdecafbad))) Expect(frame.Offset).To(Equal(protocol.ByteCount(0xdecafbad)))
Expect(r.Len()).To(BeZero()) Expect(r.Len()).To(BeZero())
}) })
@ -37,7 +37,7 @@ var _ = Describe("STREAM frame", func() {
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Expect(frame.StreamID).To(Equal(protocol.StreamID(0x12345))) Expect(frame.StreamID).To(Equal(protocol.StreamID(0x12345)))
Expect(frame.Data).To(Equal([]byte("foob"))) Expect(frame.Data).To(Equal([]byte("foob")))
Expect(frame.FinBit).To(BeFalse()) Expect(frame.Fin).To(BeFalse())
Expect(frame.Offset).To(BeZero()) Expect(frame.Offset).To(BeZero())
Expect(r.Len()).To(Equal(2)) Expect(r.Len()).To(Equal(2))
}) })
@ -51,7 +51,7 @@ var _ = Describe("STREAM frame", func() {
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Expect(frame.StreamID).To(Equal(protocol.StreamID(9))) Expect(frame.StreamID).To(Equal(protocol.StreamID(9)))
Expect(frame.Data).To(Equal([]byte("foobar"))) Expect(frame.Data).To(Equal([]byte("foobar")))
Expect(frame.FinBit).To(BeTrue()) Expect(frame.Fin).To(BeTrue())
Expect(frame.Offset).To(BeZero()) Expect(frame.Offset).To(BeZero())
Expect(r.Len()).To(BeZero()) Expect(r.Len()).To(BeZero())
}) })
@ -66,7 +66,7 @@ var _ = Describe("STREAM frame", func() {
Expect(f.StreamID).To(Equal(protocol.StreamID(0x1337))) Expect(f.StreamID).To(Equal(protocol.StreamID(0x1337)))
Expect(f.Offset).To(Equal(protocol.ByteCount(0x12345))) Expect(f.Offset).To(Equal(protocol.ByteCount(0x12345)))
Expect(f.Data).To(BeEmpty()) Expect(f.Data).To(BeEmpty())
Expect(f.FinBit).To(BeFalse()) Expect(f.Fin).To(BeFalse())
}) })
It("rejects frames that overflow the maximum offset", func() { It("rejects frames that overflow the maximum offset", func() {
@ -115,7 +115,7 @@ var _ = Describe("STREAM frame", func() {
Expect(frame.StreamID).To(Equal(protocol.StreamID(0x12345))) Expect(frame.StreamID).To(Equal(protocol.StreamID(0x12345)))
Expect(frame.Data).To(Equal(bytes.Repeat([]byte{'f'}, protocol.MinStreamFrameBufferSize))) Expect(frame.Data).To(Equal(bytes.Repeat([]byte{'f'}, protocol.MinStreamFrameBufferSize)))
Expect(frame.DataLen()).To(BeEquivalentTo(protocol.MinStreamFrameBufferSize)) Expect(frame.DataLen()).To(BeEquivalentTo(protocol.MinStreamFrameBufferSize))
Expect(frame.FinBit).To(BeFalse()) Expect(frame.Fin).To(BeFalse())
Expect(frame.fromPool).To(BeTrue()) Expect(frame.fromPool).To(BeTrue())
Expect(r.Len()).To(BeZero()) Expect(r.Len()).To(BeZero())
Expect(frame.PutBack).ToNot(Panic()) Expect(frame.PutBack).ToNot(Panic())
@ -131,7 +131,7 @@ var _ = Describe("STREAM frame", func() {
Expect(frame.StreamID).To(Equal(protocol.StreamID(0x12345))) Expect(frame.StreamID).To(Equal(protocol.StreamID(0x12345)))
Expect(frame.Data).To(Equal(bytes.Repeat([]byte{'f'}, protocol.MinStreamFrameBufferSize-1))) Expect(frame.Data).To(Equal(bytes.Repeat([]byte{'f'}, protocol.MinStreamFrameBufferSize-1)))
Expect(frame.DataLen()).To(BeEquivalentTo(protocol.MinStreamFrameBufferSize - 1)) Expect(frame.DataLen()).To(BeEquivalentTo(protocol.MinStreamFrameBufferSize - 1))
Expect(frame.FinBit).To(BeFalse()) Expect(frame.Fin).To(BeFalse())
Expect(frame.fromPool).To(BeFalse()) Expect(frame.fromPool).To(BeFalse())
Expect(r.Len()).To(BeZero()) Expect(r.Len()).To(BeZero())
Expect(frame.PutBack).ToNot(Panic()) Expect(frame.PutBack).ToNot(Panic())
@ -173,7 +173,7 @@ var _ = Describe("STREAM frame", func() {
f := &StreamFrame{ f := &StreamFrame{
StreamID: 0x1337, StreamID: 0x1337,
Offset: 0x123456, Offset: 0x123456,
FinBit: true, Fin: true,
} }
b := &bytes.Buffer{} b := &bytes.Buffer{}
err := f.Write(b, versionIETFFrames) err := f.Write(b, versionIETFFrames)
@ -373,7 +373,7 @@ var _ = Describe("STREAM frame", func() {
It("preserves the FIN bit", func() { It("preserves the FIN bit", func() {
f := &StreamFrame{ f := &StreamFrame{
StreamID: 0x1337, StreamID: 0x1337,
FinBit: true, Fin: true,
Offset: 0xdeadbeef, Offset: 0xdeadbeef,
Data: make([]byte, 100), Data: make([]byte, 100),
} }
@ -381,8 +381,8 @@ var _ = Describe("STREAM frame", func() {
Expect(needsSplit).To(BeTrue()) Expect(needsSplit).To(BeTrue())
Expect(frame).ToNot(BeNil()) Expect(frame).ToNot(BeNil())
Expect(frame.Offset).To(BeNumerically("<", f.Offset)) Expect(frame.Offset).To(BeNumerically("<", f.Offset))
Expect(f.FinBit).To(BeTrue()) Expect(f.Fin).To(BeTrue())
Expect(frame.FinBit).To(BeFalse()) Expect(frame.Fin).To(BeFalse())
}) })
It("produces frames of the correct length, without data len", func() { It("produces frames of the correct length, without data len", func() {

View file

@ -566,7 +566,7 @@ var _ = Describe("Packet packer", func() {
It("pads if payload length + packet number length is smaller than 4", func() { It("pads if payload length + packet number length is smaller than 4", func() {
f := &wire.StreamFrame{ f := &wire.StreamFrame{
StreamID: 0x10, // small stream ID, such that only a single byte is consumed StreamID: 0x10, // small stream ID, such that only a single byte is consumed
FinBit: true, Fin: true,
} }
Expect(f.Length(packer.version)).To(BeEquivalentTo(2)) Expect(f.Length(packer.version)).To(BeEquivalentTo(2))
pnManager.EXPECT().PeekPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen1) pnManager.EXPECT().PeekPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen1)
@ -599,7 +599,7 @@ var _ = Describe("Packet packer", func() {
Expect(frame).To(BeAssignableToTypeOf(&wire.StreamFrame{})) Expect(frame).To(BeAssignableToTypeOf(&wire.StreamFrame{}))
sf := frame.(*wire.StreamFrame) sf := frame.(*wire.StreamFrame)
Expect(sf.StreamID).To(Equal(f.StreamID)) Expect(sf.StreamID).To(Equal(f.StreamID))
Expect(sf.FinBit).To(Equal(f.FinBit)) Expect(sf.Fin).To(Equal(f.Fin))
Expect(sf.Data).To(BeEmpty()) Expect(sf.Data).To(BeEmpty())
Expect(r.Len()).To(BeZero()) Expect(r.Len()).To(BeZero())
}) })

View file

@ -53,7 +53,7 @@ func transformFrame(wf wire.Frame) *frame {
StreamID: f.StreamID, StreamID: f.StreamID,
Offset: f.Offset, Offset: f.Offset,
Length: f.DataLen(), Length: f.DataLen(),
FinBit: f.FinBit, FinBit: f.Fin,
}} }}
default: default:
return &frame{Frame: wf} return &frame{Frame: wf}

View file

@ -143,7 +143,7 @@ var _ = Describe("Frames", func() {
&wire.StreamFrame{ &wire.StreamFrame{
StreamID: 42, StreamID: 42,
Offset: 1337, Offset: 1337,
FinBit: true, Fin: true,
Data: []byte("foobar"), Data: []byte("foobar"),
}, },
map[string]interface{}{ map[string]interface{}{

View file

@ -271,7 +271,7 @@ var _ = Describe("Tracer", func() {
nil, nil,
[]wire.Frame{ []wire.Frame{
&wire.MaxStreamDataFrame{StreamID: 42, MaximumStreamData: 987}, &wire.MaxStreamDataFrame{StreamID: 42, MaximumStreamData: 987},
&wire.StreamFrame{StreamID: 123, Offset: 1234, Data: []byte("foobar"), FinBit: true}, &wire.StreamFrame{StreamID: 123, Offset: 1234, Data: []byte("foobar"), Fin: true},
}, },
) )
entry := exportAndParseSingle() entry := exportAndParseSingle()
@ -328,7 +328,7 @@ var _ = Describe("Tracer", func() {
789, 789,
[]wire.Frame{ []wire.Frame{
&wire.MaxStreamDataFrame{StreamID: 42, MaximumStreamData: 987}, &wire.MaxStreamDataFrame{StreamID: 42, MaximumStreamData: 987},
&wire.StreamFrame{StreamID: 123, Offset: 1234, Data: []byte("foobar"), FinBit: true}, &wire.StreamFrame{StreamID: 123, Offset: 1234, Data: []byte("foobar"), Fin: true},
}, },
) )
entry := exportAndParseSingle() entry := exportAndParseSingle()

View file

@ -41,7 +41,7 @@ type receiveStream struct {
resetRemotelyErr StreamError resetRemotelyErr StreamError
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 Fin
canceledRead bool // set when CancelRead() is called canceledRead bool // set when CancelRead() is called
resetRemotely bool // set when HandleResetStreamFrame() is called resetRemotely bool // set when HandleResetStreamFrame() is called
@ -234,11 +234,11 @@ func (s *receiveStream) handleStreamFrame(frame *wire.StreamFrame) error {
func (s *receiveStream) handleStreamFrameImpl(frame *wire.StreamFrame) (bool /* completed */, error) { func (s *receiveStream) handleStreamFrameImpl(frame *wire.StreamFrame) (bool /* completed */, error) {
maxOffset := frame.Offset + frame.DataLen() maxOffset := frame.Offset + frame.DataLen()
if err := s.flowController.UpdateHighestReceived(maxOffset, frame.FinBit); err != nil { if err := s.flowController.UpdateHighestReceived(maxOffset, frame.Fin); err != nil {
return false, err return false, err
} }
var newlyRcvdFinalOffset bool var newlyRcvdFinalOffset bool
if frame.FinBit { if frame.Fin {
newlyRcvdFinalOffset = s.finalOffset == protocol.MaxByteCount newlyRcvdFinalOffset = s.finalOffset == protocol.MaxByteCount
s.finalOffset = maxOffset s.finalOffset = maxOffset
} }
@ -288,7 +288,7 @@ func (s *receiveStream) handleResetStreamFrameImpl(frame *wire.ResetStreamFrame)
} }
func (s *receiveStream) CloseRemote(offset protocol.ByteCount) { func (s *receiveStream) CloseRemote(offset protocol.ByteCount) {
s.handleStreamFrame(&wire.StreamFrame{FinBit: true, Offset: offset}) s.handleStreamFrame(&wire.StreamFrame{Fin: true, Offset: offset})
} }
func (s *receiveStream) SetReadDeadline(t time.Time) error { func (s *receiveStream) SetReadDeadline(t time.Time) error {

View file

@ -332,7 +332,7 @@ var _ = Describe("Receive Stream", func() {
str.handleStreamFrame(&wire.StreamFrame{ str.handleStreamFrame(&wire.StreamFrame{
Offset: 0, Offset: 0,
Data: []byte{0xDE, 0xAD, 0xBE, 0xEF}, Data: []byte{0xDE, 0xAD, 0xBE, 0xEF},
FinBit: true, Fin: true,
}) })
mockSender.EXPECT().onStreamCompleted(streamID) mockSender.EXPECT().onStreamCompleted(streamID)
b := make([]byte, 4) b := make([]byte, 4)
@ -352,7 +352,7 @@ var _ = Describe("Receive Stream", func() {
frame1 := wire.StreamFrame{ frame1 := wire.StreamFrame{
Offset: 2, Offset: 2,
Data: []byte{0xBE, 0xEF}, Data: []byte{0xBE, 0xEF},
FinBit: true, Fin: true,
} }
frame2 := wire.StreamFrame{ frame2 := wire.StreamFrame{
Offset: 0, Offset: 0,
@ -379,7 +379,7 @@ var _ = Describe("Receive Stream", func() {
err := str.handleStreamFrame(&wire.StreamFrame{ err := str.handleStreamFrame(&wire.StreamFrame{
Offset: 0, Offset: 0,
Data: []byte{0xde, 0xad}, Data: []byte{0xde, 0xad},
FinBit: true, Fin: true,
}) })
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
mockSender.EXPECT().onStreamCompleted(streamID) mockSender.EXPECT().onStreamCompleted(streamID)
@ -395,7 +395,7 @@ var _ = Describe("Receive Stream", func() {
mockFC.EXPECT().AddBytesRead(protocol.ByteCount(0)) mockFC.EXPECT().AddBytesRead(protocol.ByteCount(0))
err := str.handleStreamFrame(&wire.StreamFrame{ err := str.handleStreamFrame(&wire.StreamFrame{
Offset: 0, Offset: 0,
FinBit: true, Fin: true,
}) })
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
mockSender.EXPECT().onStreamCompleted(streamID) mockSender.EXPECT().onStreamCompleted(streamID)
@ -492,7 +492,7 @@ var _ = Describe("Receive Stream", func() {
Expect(str.handleStreamFrame(&wire.StreamFrame{ Expect(str.handleStreamFrame(&wire.StreamFrame{
StreamID: streamID, StreamID: streamID,
Data: []byte("foobar"), Data: []byte("foobar"),
FinBit: true, Fin: true,
})).To(Succeed()) })).To(Succeed())
mockSender.EXPECT().onStreamCompleted(streamID) mockSender.EXPECT().onStreamCompleted(streamID)
_, err := strWithTimeout.Read(make([]byte, 100)) _, err := strWithTimeout.Read(make([]byte, 100))
@ -517,7 +517,7 @@ var _ = Describe("Receive Stream", func() {
mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(1000), true) mockFC.EXPECT().UpdateHighestReceived(protocol.ByteCount(1000), true)
Expect(str.handleStreamFrame(&wire.StreamFrame{ Expect(str.handleStreamFrame(&wire.StreamFrame{
Offset: 1000, Offset: 1000,
FinBit: true, Fin: true,
})).To(Succeed()) })).To(Succeed())
mockFC.EXPECT().Abandon() mockFC.EXPECT().Abandon()
mockSender.EXPECT().queueControlFrame(gomock.Any()) mockSender.EXPECT().queueControlFrame(gomock.Any())
@ -525,7 +525,7 @@ var _ = Describe("Receive Stream", func() {
str.CancelRead(1234) str.CancelRead(1234)
}) })
It("completes the stream when receiving the FinBit after the stream was canceled", func() { It("completes the stream when receiving the Fin after the stream was canceled", func() {
mockSender.EXPECT().queueControlFrame(gomock.Any()) mockSender.EXPECT().queueControlFrame(gomock.Any())
str.CancelRead(1234) str.CancelRead(1234)
gomock.InOrder( gomock.InOrder(
@ -535,7 +535,7 @@ var _ = Describe("Receive Stream", func() {
mockSender.EXPECT().onStreamCompleted(streamID) mockSender.EXPECT().onStreamCompleted(streamID)
Expect(str.handleStreamFrame(&wire.StreamFrame{ Expect(str.handleStreamFrame(&wire.StreamFrame{
Offset: 1000, Offset: 1000,
FinBit: true, Fin: true,
})).To(Succeed()) })).To(Succeed())
}) })
@ -550,11 +550,11 @@ var _ = Describe("Receive Stream", func() {
mockSender.EXPECT().onStreamCompleted(streamID) mockSender.EXPECT().onStreamCompleted(streamID)
Expect(str.handleStreamFrame(&wire.StreamFrame{ Expect(str.handleStreamFrame(&wire.StreamFrame{
Offset: 1000, Offset: 1000,
FinBit: true, Fin: true,
})).To(Succeed()) })).To(Succeed())
Expect(str.handleStreamFrame(&wire.StreamFrame{ Expect(str.handleStreamFrame(&wire.StreamFrame{
Offset: 1000, Offset: 1000,
FinBit: true, Fin: true,
})).To(Succeed()) })).To(Succeed())
}) })
}) })
@ -616,7 +616,7 @@ var _ = Describe("Receive Stream", func() {
Expect(str.handleResetStreamFrame(rst)).To(Succeed()) Expect(str.handleResetStreamFrame(rst)).To(Succeed())
}) })
It("doesn't call onStreamCompleted again when the final offset was already received via FinBit", func() { It("doesn't call onStreamCompleted again when the final offset was already received via Fin", func() {
mockSender.EXPECT().queueControlFrame(gomock.Any()) mockSender.EXPECT().queueControlFrame(gomock.Any())
str.CancelRead(1234) str.CancelRead(1234)
mockSender.EXPECT().onStreamCompleted(streamID) mockSender.EXPECT().onStreamCompleted(streamID)
@ -625,7 +625,7 @@ var _ = Describe("Receive Stream", func() {
Expect(str.handleStreamFrame(&wire.StreamFrame{ Expect(str.handleStreamFrame(&wire.StreamFrame{
StreamID: streamID, StreamID: streamID,
Offset: rst.FinalSize, Offset: rst.FinalSize,
FinBit: true, Fin: true,
})).To(Succeed()) })).To(Succeed())
Expect(str.handleResetStreamFrame(rst)).To(Succeed()) Expect(str.handleResetStreamFrame(rst)).To(Succeed())
}) })

View file

@ -232,7 +232,7 @@ func (s *sendStream) popNewOrRetransmittedStreamFrame(maxBytes protocol.ByteCoun
StreamID: s.streamID, StreamID: s.streamID,
Offset: s.writeOffset, Offset: s.writeOffset,
DataLenPresent: true, DataLenPresent: true,
FinBit: true, Fin: true,
}, false }, false
} }
return nil, false return nil, false
@ -255,8 +255,8 @@ func (s *sendStream) popNewOrRetransmittedStreamFrame(maxBytes protocol.ByteCoun
s.writeOffset += f.DataLen() s.writeOffset += f.DataLen()
s.flowController.AddBytesSent(f.DataLen()) s.flowController.AddBytesSent(f.DataLen())
} }
f.FinBit = s.finishedWriting && s.dataForWriting == nil && s.nextFrame == nil && !s.finSent f.Fin = s.finishedWriting && s.dataForWriting == nil && s.nextFrame == nil && !s.finSent
if f.FinBit { if f.Fin {
s.finSent = true s.finSent = true
} }
return f, hasMoreData return f, hasMoreData
@ -283,14 +283,14 @@ func (s *sendStream) popNewStreamFrame(maxBytes, sendWindow protocol.ByteCount)
} }
f := wire.GetStreamFrame() f := wire.GetStreamFrame()
f.FinBit = false f.Fin = false
f.StreamID = s.streamID f.StreamID = s.streamID
f.Offset = s.writeOffset f.Offset = s.writeOffset
f.DataLenPresent = true f.DataLenPresent = true
f.Data = f.Data[:0] f.Data = f.Data[:0]
hasMoreData := s.popNewStreamFrameWithoutBuffer(f, maxBytes, sendWindow) hasMoreData := s.popNewStreamFrameWithoutBuffer(f, maxBytes, sendWindow)
if len(f.Data) == 0 && !f.FinBit { if len(f.Data) == 0 && !f.Fin {
f.PutBack() f.PutBack()
return nil, hasMoreData return nil, hasMoreData
} }

View file

@ -88,7 +88,7 @@ var _ = Describe("Send Stream", func() {
frame, _ := str.popStreamFrame(protocol.MaxByteCount) frame, _ := str.popStreamFrame(protocol.MaxByteCount)
f := frame.Frame.(*wire.StreamFrame) f := frame.Frame.(*wire.StreamFrame)
Expect(f.Data).To(Equal([]byte("foobar"))) Expect(f.Data).To(Equal([]byte("foobar")))
Expect(f.FinBit).To(BeFalse()) Expect(f.Fin).To(BeFalse())
Expect(f.Offset).To(BeZero()) Expect(f.Offset).To(BeZero())
Expect(f.DataLenPresent).To(BeTrue()) Expect(f.DataLenPresent).To(BeTrue())
Expect(str.writeOffset).To(Equal(protocol.ByteCount(6))) Expect(str.writeOffset).To(Equal(protocol.ByteCount(6)))
@ -112,13 +112,13 @@ var _ = Describe("Send Stream", func() {
frame, _ := str.popStreamFrame(expectedFrameHeaderLen(0) + 3) frame, _ := str.popStreamFrame(expectedFrameHeaderLen(0) + 3)
f := frame.Frame.(*wire.StreamFrame) f := frame.Frame.(*wire.StreamFrame)
Expect(f.Offset).To(BeZero()) Expect(f.Offset).To(BeZero())
Expect(f.FinBit).To(BeFalse()) Expect(f.Fin).To(BeFalse())
Expect(f.Data).To(Equal([]byte("foo"))) Expect(f.Data).To(Equal([]byte("foo")))
Expect(f.DataLenPresent).To(BeTrue()) Expect(f.DataLenPresent).To(BeTrue())
frame, _ = str.popStreamFrame(protocol.MaxByteCount) frame, _ = str.popStreamFrame(protocol.MaxByteCount)
f = frame.Frame.(*wire.StreamFrame) f = frame.Frame.(*wire.StreamFrame)
Expect(f.Data).To(Equal([]byte("bar"))) Expect(f.Data).To(Equal([]byte("bar")))
Expect(f.FinBit).To(BeFalse()) Expect(f.Fin).To(BeFalse())
Expect(f.Offset).To(Equal(protocol.ByteCount(3))) Expect(f.Offset).To(Equal(protocol.ByteCount(3)))
Expect(f.DataLenPresent).To(BeTrue()) Expect(f.DataLenPresent).To(BeTrue())
Expect(str.popStreamFrame(1000)).To(BeNil()) Expect(str.popStreamFrame(1000)).To(BeNil())
@ -144,7 +144,7 @@ var _ = Describe("Send Stream", func() {
frame, _ := str.popStreamFrame(protocol.MaxByteCount) frame, _ := str.popStreamFrame(protocol.MaxByteCount)
f := frame.Frame.(*wire.StreamFrame) f := frame.Frame.(*wire.StreamFrame)
Expect(f.Offset).To(BeZero()) Expect(f.Offset).To(BeZero())
Expect(f.FinBit).To(BeFalse()) Expect(f.Fin).To(BeFalse())
Expect(f.Data).To(Equal([]byte("foobar"))) Expect(f.Data).To(Equal([]byte("foobar")))
}) })
@ -166,7 +166,7 @@ var _ = Describe("Send Stream", func() {
frame, _ := str.popStreamFrame(1100) frame, _ := str.popStreamFrame(1100)
f := frame.Frame.(*wire.StreamFrame) f := frame.Frame.(*wire.StreamFrame)
Expect(f.Offset).To(BeNumerically("~", 1100*i, 10*i)) Expect(f.Offset).To(BeNumerically("~", 1100*i, 10*i))
Expect(f.FinBit).To(BeFalse()) Expect(f.Fin).To(BeFalse())
Expect(f.Data).To(Equal(getDataAtOffset(f.Offset, f.DataLen()))) Expect(f.Data).To(Equal(getDataAtOffset(f.Offset, f.DataLen())))
Expect(f.DataLenPresent).To(BeTrue()) Expect(f.DataLenPresent).To(BeTrue())
} }
@ -248,11 +248,11 @@ var _ = Describe("Send Stream", func() {
mockFC.EXPECT().AddBytesSent(gomock.Any()).Times(2) mockFC.EXPECT().AddBytesSent(gomock.Any()).Times(2)
frame, hasMoreData := str.popStreamFrame(50) frame, hasMoreData := str.popStreamFrame(50)
Expect(frame).ToNot(BeNil()) Expect(frame).ToNot(BeNil())
Expect(frame.Frame.(*wire.StreamFrame).FinBit).To(BeFalse()) Expect(frame.Frame.(*wire.StreamFrame).Fin).To(BeFalse())
Expect(hasMoreData).To(BeTrue()) Expect(hasMoreData).To(BeTrue())
frame, hasMoreData = str.popStreamFrame(protocol.MaxByteCount) frame, hasMoreData = str.popStreamFrame(protocol.MaxByteCount)
Expect(frame).ToNot(BeNil()) Expect(frame).ToNot(BeNil())
Expect(frame.Frame.(*wire.StreamFrame).FinBit).To(BeFalse()) Expect(frame.Frame.(*wire.StreamFrame).Fin).To(BeFalse())
Expect(hasMoreData).To(BeFalse()) Expect(hasMoreData).To(BeFalse())
frame, _ = str.popStreamFrame(protocol.MaxByteCount) frame, _ = str.popStreamFrame(protocol.MaxByteCount)
Expect(frame).To(BeNil()) Expect(frame).To(BeNil())
@ -533,7 +533,7 @@ var _ = Describe("Send Stream", func() {
Expect(frame).ToNot(BeNil()) Expect(frame).ToNot(BeNil())
f := frame.Frame.(*wire.StreamFrame) f := frame.Frame.(*wire.StreamFrame)
Expect(f.Data).To(BeEmpty()) Expect(f.Data).To(BeEmpty())
Expect(f.FinBit).To(BeTrue()) Expect(f.Fin).To(BeTrue())
Expect(f.DataLenPresent).To(BeTrue()) Expect(f.DataLenPresent).To(BeTrue())
Expect(hasMoreData).To(BeFalse()) Expect(hasMoreData).To(BeFalse())
}) })
@ -550,11 +550,11 @@ var _ = Describe("Send Stream", func() {
Expect(frame).ToNot(BeNil()) Expect(frame).ToNot(BeNil())
f := frame.Frame.(*wire.StreamFrame) f := frame.Frame.(*wire.StreamFrame)
Expect(f.Data).To(Equal([]byte("foo"))) Expect(f.Data).To(Equal([]byte("foo")))
Expect(f.FinBit).To(BeFalse()) Expect(f.Fin).To(BeFalse())
frame, _ = str.popStreamFrame(protocol.MaxByteCount) frame, _ = str.popStreamFrame(protocol.MaxByteCount)
f = frame.Frame.(*wire.StreamFrame) f = frame.Frame.(*wire.StreamFrame)
Expect(f.Data).To(Equal([]byte("bar"))) Expect(f.Data).To(Equal([]byte("bar")))
Expect(f.FinBit).To(BeTrue()) Expect(f.Fin).To(BeTrue())
}) })
It("doesn't send a FIN when there's still data, for long writes", func() { It("doesn't send a FIN when there's still data, for long writes", func() {
@ -579,7 +579,7 @@ var _ = Describe("Send Stream", func() {
Expect(frame).ToNot(BeNil()) Expect(frame).ToNot(BeNil())
f := frame.Frame.(*wire.StreamFrame) f := frame.Frame.(*wire.StreamFrame)
Expect(f.Data).To(Equal(getDataAtOffset(f.Offset, f.DataLen()))) Expect(f.Data).To(Equal(getDataAtOffset(f.Offset, f.DataLen())))
Expect(f.FinBit).To(Equal(i == 5)) // the last frame should have the FIN bit set Expect(f.Fin).To(Equal(i == 5)) // the last frame should have the FIN bit set
} }
}) })
@ -602,7 +602,7 @@ var _ = Describe("Send Stream", func() {
Expect(frame).ToNot(BeNil()) Expect(frame).ToNot(BeNil())
f := frame.Frame.(*wire.StreamFrame) f := frame.Frame.(*wire.StreamFrame)
Expect(f.Data).To(BeEmpty()) Expect(f.Data).To(BeEmpty())
Expect(f.FinBit).To(BeTrue()) Expect(f.Fin).To(BeTrue())
frame, hasMoreData := str.popStreamFrame(1000) frame, hasMoreData := str.popStreamFrame(1000)
Expect(frame).To(BeNil()) Expect(frame).To(BeNil())
Expect(hasMoreData).To(BeFalse()) Expect(hasMoreData).To(BeFalse())
@ -1035,7 +1035,7 @@ var _ = Describe("Send Stream", func() {
frame, hasMoreData := str.popStreamFrame(protocol.MaxByteCount) frame, hasMoreData := str.popStreamFrame(protocol.MaxByteCount)
Expect(hasMoreData).To(BeFalse()) Expect(hasMoreData).To(BeFalse())
Expect(frame).ToNot(BeNil()) Expect(frame).ToNot(BeNil())
Expect(frame.Frame.(*wire.StreamFrame).FinBit).To(BeTrue()) Expect(frame.Frame.(*wire.StreamFrame).Fin).To(BeTrue())
mockSender.EXPECT().onStreamCompleted(streamID) mockSender.EXPECT().onStreamCompleted(streamID)
frame.OnAcked(frame.Frame) frame.OnAcked(frame.Frame)
@ -1062,7 +1062,7 @@ var _ = Describe("Send Stream", func() {
continue continue
} }
frames = append(frames, *frame) frames = append(frames, *frame)
if frame.Frame.(*wire.StreamFrame).FinBit { if frame.Frame.(*wire.StreamFrame).Fin {
break break
} }
} }