return error empty StreamFrames that don't have the FinBit set

This commit is contained in:
Marten Seemann
2016-05-22 12:55:21 +07:00
parent 68f450d549
commit 33de224ce0
2 changed files with 21 additions and 0 deletions

View File

@@ -4,6 +4,7 @@ import (
"bytes"
"github.com/lucas-clemente/quic-go/protocol"
"github.com/lucas-clemente/quic-go/qerr"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
@@ -31,6 +32,21 @@ var _ = Describe("StreamFrame", func() {
Expect(frame.DataLenPresent).To(BeFalse())
Expect(frame.Data).To(Equal([]byte("foobar")))
})
It("accepts empty frame with finbit set", func() {
b := bytes.NewReader([]byte{0x80 ^ 0x40 ^ 0x20, 0x1, 0, 0})
frame, err := ParseStreamFrame(b)
Expect(err).ToNot(HaveOccurred())
Expect(frame.FinBit).To(BeTrue())
Expect(frame.DataLenPresent).To(BeTrue())
Expect(frame.Data).To(HaveLen(0))
})
It("errors on empty stream frames that don't have the FinBit set", func() {
b := bytes.NewReader([]byte{0x80 ^ 0x20, 0x1, 0, 0})
_, err := ParseStreamFrame(b)
Expect(err).To(MatchError(qerr.EmptyStreamFrameNoFin))
})
})
Context("when writing", func() {