예제 #1
0
        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));
        }
예제 #2
0
        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));
        }
예제 #3
0
 public int GetWindowSize(IHttp2Stream stream)
 {
     return(_flowController.GetWindowSize(stream));
 }