trigger sending when stream data is read

fixes #223
This commit is contained in:
Lucas Clemente
2016-07-28 16:52:04 +02:00
parent 3a88a8cffa
commit 3d0ed0d1f9
2 changed files with 12 additions and 0 deletions

View File

@@ -118,6 +118,7 @@ func (s *stream) Read(p []byte) (int, error) {
s.readOffset += protocol.ByteCount(m)
s.flowControlManager.AddBytesRead(s.streamID, protocol.ByteCount(m))
s.onData() // so that a possible WINDOW_UPDATE is sent
if s.readPosInFrame >= int(frame.DataLen()) {
fin := frame.FinBit

View File

@@ -288,6 +288,17 @@ var _ = Describe("Stream", func() {
Expect(err).To(MatchError(errOverlappingStreamData))
})
It("calls onData", func() {
frame := frames.StreamFrame{
Offset: 0,
Data: []byte{0xDE, 0xAD, 0xBE, 0xEF},
}
str.AddStreamFrame(&frame)
b := make([]byte, 4)
_, err := str.Read(b)
Expect(err).ToNot(HaveOccurred())
Expect(onDataCalled).To(BeTrue())
})
})
Context("writing", func() {