public DefaultHttp2RemoteFlowController(IHttp2Connection connection, IStreamByteDistributor streamByteDistributor, IHttp2RemoteFlowControllerListener listener) { if (connection is null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.connection); } if (streamByteDistributor is null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.streamByteDistributor); } _connection = connection; _streamByteDistributor = streamByteDistributor; // Add a flow state for the connection. _stateKey = connection.NewKey(); _connectionState = new FlowState(this, _connection.ConnectionStream); _ = connection.ConnectionStream.SetProperty(_stateKey, _connectionState); // Monitor may depend upon connectionState, and so initialize after connectionState Listener(listener); _monitor.WindowSize(_connectionState, _initialWindowSize); // Register for notification of new streams. connection.AddListener(this); }
public WeightedFairQueueByteDistributor(IHttp2Connection connection, int maxStateOnlySize) { uint uMaxStateOnlySize = (uint)maxStateOnlySize; if (uMaxStateOnlySize > SharedConstants.TooBigOrNegative) { ThrowHelper.ThrowArgumentException_PositiveOrZero(maxStateOnlySize, ExceptionArgument.maxStateOnlySize); } if (0u >= uMaxStateOnlySize) { _stateOnlyMap = EmptyDictionary <int, State> .Instance; _stateOnlyRemovalQueue = EmptyPriorityQueue <State> .Instance; } else { _stateOnlyMap = new Dictionary <int, State>(maxStateOnlySize); // +2 because we may exceed the limit by 2 if a new dependency has no associated IHttp2Stream object. We need // to create the State objects to put them into the dependency tree, which then impacts priority. _stateOnlyRemovalQueue = new PriorityQueue <State>(StateOnlyComparator.Instance, maxStateOnlySize + 2); } _maxStateOnlySize = maxStateOnlySize; _connection = connection; _stateKey = connection.NewKey(); IHttp2Stream connectionStream = connection.ConnectionStream; _ = connectionStream.SetProperty(_stateKey, _connectionState = new State(this, connectionStream, 16)); // Register for notification of new streams. connection.AddListener(this); }
public DelegatingDecompressorFrameListener(IHttp2Connection connection, IHttp2FrameListener listener, bool strict) : base(listener) { _connection = connection; _strict = strict; _propertyKey = connection.NewKey(); _connection.AddListener(new DelegatingConnectionAdapter(this)); }
public UniformStreamByteDistributor(IHttp2Connection connection) { // Add a state for the connection. _stateKey = connection.NewKey(); var connectionStream = connection.ConnectionStream; _ = connectionStream.SetProperty(_stateKey, new State(this, connectionStream)); // Register for notification of new streams. connection.AddListener(this); }
public InboundHttp2ToHttpAdapter(IHttp2Connection connection, int maxContentLength, bool validateHttpHeaders, bool propagateSettings) { if (connection is null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.connection); } if ((uint)(maxContentLength - 1) > SharedConstants.TooBigOrNegative) { ThrowHelper.ThrowArgumentException_Positive(maxContentLength, ExceptionArgument.maxContentLength); } _connection = connection; _maxContentLength = maxContentLength; _validateHttpHeaders = validateHttpHeaders; _propagateSettings = propagateSettings; _sendDetector = DefaultImmediateSendDetector.Instance; _messageKey = connection.NewKey(); }
/// <summary> /// Constructs a controller with the given settings. /// </summary> /// <param name="connection">the connection state.</param> /// <param name="windowUpdateRatio">the window percentage below which to send a <c>WINDOW_UPDATE</c>.</param> /// <param name="autoRefillConnectionWindow">if <c>true</c>, effectively disables the connection window /// in the flow control algorithm as they will always refill automatically without requiring the /// application to consume the bytes. When enabled, the maximum bytes you must be prepared to /// queue is proportional to <c>maximum number of concurrent streams * the initial window /// size per stream</c> /// (<a href="https://tools.ietf.org/html/rfc7540#section-6.5.2">SETTINGS_MAX_CONCURRENT_STREAMS</a> /// <a href="https://tools.ietf.org/html/rfc7540#section-6.5.2">SETTINGS_INITIAL_WINDOW_SIZE</a>). /// </param> public DefaultHttp2LocalFlowController(IHttp2Connection connection, float windowUpdateRatio, bool autoRefillConnectionWindow) { if (connection is null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.connection); } _connection = connection; WindowUpdateRatio(windowUpdateRatio); // Add a flow state for the connection. _stateKey = connection.NewKey(); IFlowState connectionState = autoRefillConnectionWindow ? new AutoRefillState(this, connection.ConnectionStream, _initialWindowSize) : new DefaultState(this, connection.ConnectionStream, _initialWindowSize); _ = connection.ConnectionStream.SetProperty(_stateKey, connectionState); // Register for notification of new streams. connection.AddListener(this); }