use IETF QUIC transport error codes

This commit is contained in:
Marten Seemann
2019-03-06 13:19:21 +09:00
parent 966b00dd3d
commit 9c09e84765
34 changed files with 156 additions and 333 deletions

View File

@@ -49,7 +49,7 @@ func (c *connectionFlowController) IncrementHighestReceived(increment protocol.B
c.highestReceived += increment
if c.checkFlowControlViolation() {
return qerr.Error(qerr.FlowControlReceivedTooMuchData, fmt.Sprintf("Received %d bytes for the connection, allowed %d bytes", c.highestReceived, c.receiveWindow))
return qerr.Error(qerr.FlowControlError, fmt.Sprintf("Received %d bytes for the connection, allowed %d bytes", c.highestReceived, c.receiveWindow))
}
return nil
}

View File

@@ -58,11 +58,11 @@ func (c *streamFlowController) UpdateHighestReceived(offset protocol.ByteCount,
if c.receivedFinalOffset {
// If we receive another final offset, check that it's the same.
if final && offset != c.highestReceived {
return qerr.Error(qerr.StreamDataAfterTermination, fmt.Sprintf("Received inconsistent final offset for stream %d (old: %#x, new: %#x bytes)", c.streamID, c.highestReceived, offset))
return qerr.Error(qerr.FinalSizeError, fmt.Sprintf("Received inconsistent final offset for stream %d (old: %#x, new: %#x bytes)", c.streamID, c.highestReceived, offset))
}
// Check that the offset is below the final offset.
if offset > c.highestReceived {
return qerr.Error(qerr.StreamDataAfterTermination, fmt.Sprintf("Received offset %#x for stream %d. Final offset was already received at %#x", offset, c.streamID, c.highestReceived))
return qerr.Error(qerr.FinalSizeError, fmt.Sprintf("Received offset %#x for stream %d. Final offset was already received at %#x", offset, c.streamID, c.highestReceived))
}
}
@@ -76,7 +76,7 @@ func (c *streamFlowController) UpdateHighestReceived(offset protocol.ByteCount,
// This can happen due to reordering.
if offset <= c.highestReceived {
if final {
return qerr.Error(qerr.StreamDataAfterTermination, fmt.Sprintf("Received final offset %#x for stream %d, but already received offset %#x before", offset, c.streamID, c.highestReceived))
return qerr.Error(qerr.FinalSizeError, fmt.Sprintf("Received final offset %#x for stream %d, but already received offset %#x before", offset, c.streamID, c.highestReceived))
}
return nil
}
@@ -84,7 +84,7 @@ func (c *streamFlowController) UpdateHighestReceived(offset protocol.ByteCount,
increment := offset - c.highestReceived
c.highestReceived = offset
if c.checkFlowControlViolation() {
return qerr.Error(qerr.FlowControlReceivedTooMuchData, fmt.Sprintf("Received %#x bytes on stream %d, allowed %#x bytes", offset, c.streamID, c.receiveWindow))
return qerr.Error(qerr.FlowControlError, fmt.Sprintf("Received %#x bytes on stream %d, allowed %#x bytes", offset, c.streamID, c.receiveWindow))
}
return c.connection.IncrementHighestReceived(increment)
}

View File

@@ -98,7 +98,7 @@ var _ = Describe("Stream Flow controller", func() {
})
It("detects a flow control violation", func() {
Expect(controller.UpdateHighestReceived(receiveWindow+1, false)).To(MatchError("FlowControlReceivedTooMuchData: Received 0x10001 bytes on stream 10, allowed 0x10000 bytes"))
Expect(controller.UpdateHighestReceived(receiveWindow+1, false)).To(MatchError("FlowControlError: Received 0x10001 bytes on stream 10, allowed 0x10000 bytes"))
})
It("accepts a final offset higher than the highest received", func() {
@@ -109,7 +109,7 @@ var _ = Describe("Stream Flow controller", func() {
It("errors when receiving a final offset smaller than the highest offset received so far", func() {
controller.UpdateHighestReceived(0x100, false)
Expect(controller.UpdateHighestReceived(0xff, true)).To(MatchError("StreamDataAfterTermination: Received final offset 0xff for stream 10, but already received offset 0x100 before"))
Expect(controller.UpdateHighestReceived(0xff, true)).To(MatchError("FinalSizeError: Received final offset 0xff for stream 10, but already received offset 0x100 before"))
})
It("accepts delayed data after receiving a final offset", func() {
@@ -119,7 +119,7 @@ var _ = Describe("Stream Flow controller", func() {
It("errors when receiving a higher offset after receiving a final offset", func() {
Expect(controller.UpdateHighestReceived(0x200, true)).To(Succeed())
Expect(controller.UpdateHighestReceived(0x250, false)).To(MatchError("StreamDataAfterTermination: Received offset 0x250 for stream 10. Final offset was already received at 0x200"))
Expect(controller.UpdateHighestReceived(0x250, false)).To(MatchError("FinalSizeError: Received offset 0x250 for stream 10. Final offset was already received at 0x200"))
})
It("accepts duplicate final offsets", func() {
@@ -130,7 +130,7 @@ var _ = Describe("Stream Flow controller", func() {
It("errors when receiving inconsistent final offsets", func() {
Expect(controller.UpdateHighestReceived(0x200, true)).To(Succeed())
Expect(controller.UpdateHighestReceived(0x201, true)).To(MatchError("StreamDataAfterTermination: Received inconsistent final offset for stream 10 (old: 0x200, new: 0x201 bytes)"))
Expect(controller.UpdateHighestReceived(0x201, true)).To(MatchError("FinalSizeError: Received inconsistent final offset for stream 10 (old: 0x200, new: 0x201 bytes)"))
})
It("tells the connection flow controller when a stream is abandoned", func() {