public virtual void RemoteSettings(Http2Settings settings)
        {
            var pushEnabled             = settings.PushEnabled();
            var config                  = Configuration;
            var outboundHeaderConfig    = config.HeadersConfiguration;
            var outboundFrameSizePolicy = config.FrameSizePolicy;

            if (pushEnabled.HasValue)
            {
                if (!_connection.IsServer && pushEnabled.Value)
                {
                    ThrowHelper.ThrowConnectionError_ClientReceivedAValueOfEnablePushSpecifiedToOtherThan0();
                }
                _connection.Remote.AllowPushTo(pushEnabled.Value);
            }

            var maxConcurrentStreams = settings.MaxConcurrentStreams();

            if (maxConcurrentStreams.HasValue)
            {
                _connection.Local.SetMaxActiveStreams((int)Math.Min(maxConcurrentStreams.Value, int.MaxValue));
            }

            var headerTableSize = settings.HeaderTableSize();

            if (headerTableSize.HasValue)
            {
                outboundHeaderConfig.SetMaxHeaderTableSize((int)Math.Min(headerTableSize.Value, int.MaxValue));
            }

            var maxHeaderListSize = settings.MaxHeaderListSize();

            if (maxHeaderListSize.HasValue)
            {
                outboundHeaderConfig.SetMaxHeaderListSize(maxHeaderListSize.Value);
            }

            var maxFrameSize = settings.MaxFrameSize();

            if (maxFrameSize.HasValue)
            {
                outboundFrameSizePolicy.SetMaxFrameSize(maxFrameSize.Value);
            }

            var initialWindowSize = settings.InitialWindowSize();

            if (initialWindowSize.HasValue)
            {
                FlowController.SetInitialWindowSize(initialWindowSize.Value);
            }
        }
Ejemplo n.º 2
0
        public Http2FrameCodec(IHttp2ConnectionEncoder encoder, IHttp2ConnectionDecoder decoder, Http2Settings initialSettings, bool decoupleCloseAndGoAway)
            : base(decoder, encoder, initialSettings, decoupleCloseAndGoAway)
        {
            _frameStreamToInitializeMap = new ConcurrentDictionary <int, DefaultHttp2FrameStream>();

            decoder.FrameListener = new FrameListener(this);
            var connection = Connection;

            connection.AddListener(new ConnectionListener(this));
            connection.Remote.FlowController.Listener(new Http2RemoteFlowControllerListener(this));
            _streamKey  = connection.NewKey();
            _upgradeKey = connection.NewKey();
            _initialFlowControlWindowSize = initialSettings.InitialWindowSize();
        }