implement basic connection level flow control

fixes #39
This commit is contained in:
Marten Seemann
2016-05-18 17:30:08 +07:00
parent 7105b37f91
commit f147ebc9bb
11 changed files with 319 additions and 41 deletions

View File

@@ -15,13 +15,7 @@ type BlockedFrame struct {
//Write writes a BlockedFrame frame
func (f *BlockedFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error {
b.WriteByte(0x05)
if f.StreamID == 0 {
panic("Writing of connection level BlockedFrames not yet implemented.")
}
utils.WriteUint32(b, uint32(f.StreamID))
return nil
}

View File

@@ -26,6 +26,13 @@ var _ = Describe("BlockedFrame", func() {
Expect(b.Bytes()).To(Equal([]byte{0x05, 0x37, 0x13, 0x0, 0x0}))
})
It("writes a connection-level Blocked", func() {
b := &bytes.Buffer{}
frame := BlockedFrame{StreamID: 0}
frame.Write(b, 0)
Expect(b.Bytes()).To(Equal([]byte{0x05, 0, 0, 0, 0}))
})
It("has the correct min length", func() {
frame := BlockedFrame{StreamID: 3}
Expect(frame.MinLength()).To(Equal(protocol.ByteCount(5)))