actually send Blocked frames

fixes #100
This commit is contained in:
Marten Seemann
2016-05-18 12:06:14 +07:00
parent daeb601cdc
commit e0801262bc
2 changed files with 19 additions and 0 deletions

View File

@@ -185,6 +185,8 @@ func (s *stream) Write(p []byte) (int, error) {
dataWritten += dataLen
s.flowController.AddBytesSent(protocol.ByteCount(dataLen))
s.writeOffset += protocol.ByteCount(dataLen)
s.maybeTriggerBlocked()
}
return len(p), nil

View File

@@ -374,6 +374,23 @@ var _ = Describe("Stream", func() {
Expect(handler.receivedBlockedCalled).To(BeTrue())
Expect(handler.receivedBlockedForStream).To(Equal(str.streamID))
})
It("notifies the session as soon as a stream is reaching the end of the window", func() {
str.flowController.sendFlowControlWindow = 4
str.Write([]byte{0xDE, 0xCA, 0xFB, 0xAD})
Expect(handler.receivedBlockedCalled).To(BeTrue())
Expect(handler.receivedBlockedForStream).To(Equal(str.streamID))
})
It("notifies the session as soon as a stream is flow control blocked", func() {
str.flowController.sendFlowControlWindow = 2
go func() {
str.Write([]byte{0xDE, 0xCA, 0xFB, 0xAD})
}()
time.Sleep(time.Millisecond)
Expect(handler.receivedBlockedCalled).To(BeTrue())
Expect(handler.receivedBlockedForStream).To(Equal(str.streamID))
})
})
Context("flow control window updating, for receiving", func() {