From a152d2399c573aabb5201a849e2156f5b2c87536 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Thu, 26 May 2016 16:20:37 +0700 Subject: [PATCH] fix byte length calculation for split frames in StreamFrameQueue --- stream_frame_queue.go | 2 +- stream_frame_queue_test.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/stream_frame_queue.go b/stream_frame_queue.go index c7664e30..520d290a 100644 --- a/stream_frame_queue.go +++ b/stream_frame_queue.go @@ -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 } diff --git a/stream_frame_queue_test.go b/stream_frame_queue_test.go index e7a2fb47..16676dec 100644 --- a/stream_frame_queue_test.go +++ b/stream_frame_queue_test.go @@ -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)))) })