pass the byte offset of a RstStreamFrame to the flow controller

fixes #377
This commit is contained in:
Marten Seemann
2017-01-03 12:37:45 +07:00
parent 74edf9caad
commit bf0caf3c03
3 changed files with 29 additions and 2 deletions

View File

@@ -317,6 +317,30 @@ var _ = Describe("Session", func() {
Expect(err).To(MatchError("RST_STREAM received with code 42"))
})
It("passes the byte offset to the flow controller", func() {
session.streamsMap.GetOrOpenStream(5)
session.flowControlManager = newMockFlowControlHandler()
err := session.handleRstStreamFrame(&frames.RstStreamFrame{
StreamID: 5,
ByteOffset: 0x1337,
})
Expect(err).ToNot(HaveOccurred())
Expect(session.flowControlManager.(*mockFlowControlHandler).highestReceivedForStream).To(Equal(protocol.StreamID(5)))
Expect(session.flowControlManager.(*mockFlowControlHandler).highestReceived).To(Equal(protocol.ByteCount(0x1337)))
})
It("returns errors from the flow controller", func() {
session.streamsMap.GetOrOpenStream(5)
session.flowControlManager = newMockFlowControlHandler()
testErr := errors.New("flow control violation")
session.flowControlManager.(*mockFlowControlHandler).flowControlViolation = testErr
err := session.handleRstStreamFrame(&frames.RstStreamFrame{
StreamID: 5,
ByteOffset: 0x1337,
})
Expect(err).To(MatchError(testErr))
})
It("ignores the error when the stream is not known", func() {
err := session.handleFrames([]frames.Frame{&frames.RstStreamFrame{
StreamID: 5,