From d1a85d3381f634904fc292c9c0a920dd1341adfd Mon Sep 17 00:00:00 2001 From: bestgopher <84328409@qq.com> Date: Sat, 3 Feb 2024 21:50:50 +0800 Subject: [PATCH] fix(http2/transport): send an error of FLOW_CONTROL_ERROR when exceed the maximum octets According to rfc9113, if a sender receives a WINDOW_UPDATE that causes a flow-control window to exceed this maximum, it MUST terminate either the stream or the connection, as appropriate. For streams, the sender sends a RST_STREAM with an error code of FLOW_CONTROL_ERROR. Signed-off-by: bestgopher <84328409@qq.com> --- http2/transport.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/http2/transport.go b/http2/transport.go index df578b86c6..c2a5b44b3d 100644 --- a/http2/transport.go +++ b/http2/transport.go @@ -2911,6 +2911,15 @@ func (rl *clientConnReadLoop) processWindowUpdate(f *WindowUpdateFrame) error { fl = &cs.flow } if !fl.add(int32(f.Increment)) { + // For stream, the sender sends RST_STREAM with an error code of FLOW_CONTROL_ERROR + if cs != nil { + rl.endStreamError(cs, StreamError{ + StreamID: f.StreamID, + Code: ErrCodeFlowControl, + }) + return nil + } + return ConnectionError(ErrCodeFlowControl) } cc.cond.Broadcast()