private void ProcessWindowUpdateFrame(FrameHeader frameHeader) { Debug.Assert(frameHeader.Type == FrameType.WindowUpdate); if (frameHeader.Length != FrameHeader.WindowUpdateLength) { throw new Http2ProtocolException(Http2ProtocolErrorCode.FrameSizeError); } int amount = BinaryPrimitives.ReadInt32BigEndian(_incomingBuffer.ActiveSpan) & 0x7FFFFFFF; Debug.Assert(amount >= 0); if (amount == 0) { throw new Http2ProtocolException(Http2ProtocolErrorCode.ProtocolError); } _incomingBuffer.Discard(frameHeader.Length); if (frameHeader.StreamId == 0) { _connectionWindow.AdjustCredit(amount); } else { Http2Stream http2Stream = GetStream(frameHeader.StreamId); if (http2Stream == null) { // Don't wait for completion, which could happen asynchronously. Task ignored = SendRstStreamAsync(frameHeader.StreamId, Http2ProtocolErrorCode.StreamClosed); return; } http2Stream.OnWindowUpdate(amount); } }