fix byte length calculation for split frames in StreamFrameQueue

This commit is contained in:
Marten Seemann
2016-05-26 16:20:37 +07:00
parent a5e03bef8a
commit a152d2399c
2 changed files with 3 additions and 2 deletions

View File

@@ -69,7 +69,7 @@ func (q *streamFrameQueue) Pop(maxLength protocol.ByteCount) *frames.StreamFrame
splitFrame := q.maybeSplitOffFrame(frame, maxLength)
if splitFrame != nil { // StreamFrame was split
q.byteLen -= protocol.ByteCount(len(frame.Data))
q.byteLen -= protocol.ByteCount(len(splitFrame.Data))
return splitFrame
}

View File

@@ -205,10 +205,11 @@ var _ = Describe("streamFrameQueue", func() {
})
It("correctly calculates the byte length when returning a split frame", func() {
queue.Push(prioFrame1, true)
queue.Push(frame1, false)
queue.Push(frame2, false)
startByteLength := queue.ByteLen()
frame := queue.Pop(6)
Expect(frame.StreamID).To(Equal(frame1.StreamID)) // make sure the right frame was popped
Expect(queue.ByteLen()).To(Equal(startByteLength - protocol.ByteCount(len(frame.Data))))
})