forked from quic-go/quic-go
fix StreamID len in StreamFrame TypeByte if len was calculated by MinLength
fixes #166
This commit is contained in:
@@ -106,8 +106,8 @@ func (f *StreamFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) err
|
||||
|
||||
if f.streamIDLen == 0 {
|
||||
f.calculateStreamIDLength()
|
||||
typeByte ^= uint8(f.streamIDLen) - 1
|
||||
}
|
||||
typeByte ^= uint8(f.streamIDLen) - 1
|
||||
|
||||
b.WriteByte(typeByte)
|
||||
|
||||
|
||||
@@ -302,6 +302,19 @@ var _ = Describe("StreamFrame", func() {
|
||||
Expect(b.Bytes()[0] & 0x3).To(Equal(uint8(0x3)))
|
||||
Expect(b.Bytes()[1:5]).To(Equal([]byte{0xAD, 0xFB, 0xCA, 0xDE}))
|
||||
})
|
||||
|
||||
It("writes a multiple byte StreamID, after the Stream length was already determined by MinLenght()", func() {
|
||||
b := &bytes.Buffer{}
|
||||
frame := &StreamFrame{
|
||||
StreamID: 0xDECAFBAD,
|
||||
Data: []byte("foobar"),
|
||||
}
|
||||
frame.MinLength()
|
||||
err := frame.Write(b, 0)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(b.Bytes()[0] & 0x3).To(Equal(uint8(0x3)))
|
||||
Expect(b.Bytes()[1:5]).To(Equal([]byte{0xAD, 0xFB, 0xCA, 0xDE}))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user