public void StreamZeroWindowUpdateIncrementsConnectionWindow() { IHttp2Connection connection = _frameCodec.Connection; IHttp2LocalFlowController localFlow = connection.Local.FlowController; int initialWindowSizeBefore = localFlow.InitialWindowSize; IHttp2Stream connectionStream = connection.ConnectionStream; int connectionWindowSizeBefore = localFlow.GetWindowSize(connectionStream); // We only replenish the flow control window after the amount consumed drops below the following threshold. // We make the threshold very "high" so that window updates will be sent when the delta is relatively small. ((DefaultHttp2LocalFlowController)localFlow).WindowUpdateRatio(connectionStream, .999f); int windowUpdate = 1024; _channel.WriteAsync(new DefaultHttp2WindowUpdateFrame(windowUpdate)); // The initial window size is only changed by Http2Settings, so it shouldn't change. Assert.Equal(initialWindowSizeBefore, localFlow.InitialWindowSize); // The connection window should be increased by the delta amount. Assert.Equal(connectionWindowSizeBefore + windowUpdate, localFlow.GetWindowSize(connectionStream)); }
public void WindowUpdateDoesNotOverflowConnectionWindow() { IHttp2Connection connection = _frameCodec.Connection; IHttp2LocalFlowController localFlow = connection.Local.FlowController; int initialWindowSizeBefore = localFlow.InitialWindowSize; _channel.WriteAsync(new DefaultHttp2WindowUpdateFrame(int.MaxValue)); // The initial window size is only changed by Http2Settings, so it shouldn't change. Assert.Equal(initialWindowSizeBefore, localFlow.InitialWindowSize); // The connection window should be increased by the delta amount. Assert.Equal(int.MaxValue, localFlow.GetWindowSize(connection.ConnectionStream)); }
public int GetWindowSize(IHttp2Stream stream) { return(_flowController.GetWindowSize(stream)); }