public StreamInputFlowControl( Http2Stream stream, Http2FrameWriter frameWriter, InputFlowControl connectionLevelFlowControl, uint initialWindowSize, uint minWindowSizeIncrement) { _connectionLevelFlowControl = connectionLevelFlowControl; _streamLevelFlowControl = new InputFlowControl(initialWindowSize, minWindowSizeIncrement); _stream = stream; _frameWriter = frameWriter; }
public Http2StreamContext( string connectionId, HttpProtocols protocols, ServiceContext serviceContext, IFeatureCollection connectionFeatures, MemoryPool <byte> memoryPool, IPEndPoint?localEndPoint, IPEndPoint?remoteEndPoint, int streamId, IHttp2StreamLifetimeHandler streamLifetimeHandler, Http2PeerSettings clientPeerSettings, Http2PeerSettings serverPeerSettings, Http2FrameWriter frameWriter, InputFlowControl connectionInputFlowControl, OutputFlowControl connectionOutputFlowControl) : base(connectionId, protocols, connectionContext: null !, serviceContext, connectionFeatures, memoryPool, localEndPoint, remoteEndPoint, transport: null !)
public void ReadTimingNotEnforcedWhenLowConnectionInputFlowControlAvailability() { var minRate = new MinDataRate(bytesPerSecond: 100, gracePeriod: TimeSpan.FromSeconds(2)); var flowControl = new InputFlowControl(initialWindowSize: 2, minWindowSizeIncrement: 1); // Initialize timestamp var now = DateTimeOffset.UtcNow; _timeoutControl.Initialize(now.Ticks); _timeoutControl.InitializeHttp2(flowControl); _timeoutControl.StartRequestBody(minRate); _timeoutControl.StartTimingRead(); // Tick past grace period now += TimeSpan.FromSeconds(1); _timeoutControl.BytesRead(100); _timeoutControl.Tick(now); now += TimeSpan.FromSeconds(1); _timeoutControl.BytesRead(100); _timeoutControl.Tick(now); // Induce low flow control availability flowControl.TryAdvance(2); // Read 0 bytes in 1 second now += TimeSpan.FromSeconds(1); _timeoutControl.Tick(now); // Not timed out _mockTimeoutHandler.Verify(h => h.OnTimeout(It.IsAny <TimeoutReason>()), Times.Never); // Relieve low flow control availability flowControl.TryUpdateWindow(2, out _); _timeoutControl.Tick(now); // Still not timed out _mockTimeoutHandler.Verify(h => h.OnTimeout(It.IsAny <TimeoutReason>()), Times.Never); // Read 0 bytes in 1 second now += TimeSpan.FromSeconds(1); _timeoutControl.Tick(now);; // Timed out _mockTimeoutHandler.Verify(h => h.OnTimeout(TimeoutReason.ReadDataRate), Times.Once); }
public static Http2StreamContext CreateHttp2StreamContext( string connectionId = null, ServiceContext serviceContext = null, IFeatureCollection connectionFeatures = null, MemoryPool <byte> memoryPool = null, IPEndPoint localEndPoint = null, IPEndPoint remoteEndPoint = null, int?streamId = null, IHttp2StreamLifetimeHandler streamLifetimeHandler = null, Http2PeerSettings clientPeerSettings = null, Http2PeerSettings serverPeerSettings = null, Http2FrameWriter frameWriter = null, InputFlowControl connectionInputFlowControl = null, OutputFlowControl connectionOutputFlowControl = null, ITimeoutControl timeoutControl = null) { var context = new Http2StreamContext ( connectionId: connectionId ?? "TestConnectionId", protocols: HttpProtocols.Http2, altSvcHeader: null, serviceContext: serviceContext ?? CreateServiceContext(new KestrelServerOptions()), connectionFeatures: connectionFeatures ?? new FeatureCollection(), memoryPool: memoryPool ?? MemoryPool <byte> .Shared, localEndPoint: localEndPoint, remoteEndPoint: remoteEndPoint, streamId: streamId ?? 0, streamLifetimeHandler: streamLifetimeHandler, clientPeerSettings: clientPeerSettings ?? new Http2PeerSettings(), serverPeerSettings: serverPeerSettings ?? new Http2PeerSettings(), frameWriter: frameWriter, connectionInputFlowControl: connectionInputFlowControl, connectionOutputFlowControl: connectionOutputFlowControl ); context.TimeoutControl = timeoutControl; return(context); }
public void InitializeHttp2(InputFlowControl connectionInputFlowControl) { _connectionInputFlowControl = connectionInputFlowControl; }