예제 #1
0
        public async Task InitializeConnectionAsync(RequestDelegate application)
        {
            MultiplexedConnectionContext = new TestMultiplexedConnectionContext(this)
            {
                ConnectionId = "TEST"
            };

            var httpConnectionContext = new HttpMultiplexedConnectionContext(
                connectionId: MultiplexedConnectionContext.ConnectionId,
                HttpProtocols.Http3,
                altSvcHeader: null,
                connectionContext: MultiplexedConnectionContext,
                connectionFeatures: MultiplexedConnectionContext.Features,
                serviceContext: _serviceContext,
                memoryPool: _memoryPool,
                localEndPoint: null,
                remoteEndPoint: null);

            httpConnectionContext.TimeoutControl = _timeoutControl;

            _httpConnection = new HttpConnection(httpConnectionContext);
            _httpConnection.Initialize(Connection);

            // ProcessRequestAsync will create the Http3Connection
            _connectionTask = _httpConnection.ProcessRequestsAsync(new DummyApplication(application));

            Connection = (Http3Connection)_httpConnection._requestProcessor;
            Connection._streamLifetimeHandler = new LifetimeHandlerInterceptor(Connection, this);

            await GetInboundControlStream();
        }
예제 #2
0
        public static HttpMultiplexedConnectionContext CreateHttp3ConnectionContext(
            MultiplexedConnectionContext connectionContext = null,
            ServiceContext serviceContext         = null,
            IFeatureCollection connectionFeatures = null,
            MemoryPool <byte> memoryPool          = null,
            IPEndPoint localEndPoint       = null,
            IPEndPoint remoteEndPoint      = null,
            ITimeoutControl timeoutControl = null)
        {
            var http3ConnectionContext = new HttpMultiplexedConnectionContext(
                "TEST",
                HttpProtocols.Http3,
                altSvcHeader: null,
                connectionContext ?? new TestMultiplexedConnectionContext {
                ConnectionId = "TEST"
            },
                serviceContext ?? CreateServiceContext(new KestrelServerOptions()),
                connectionFeatures ?? new FeatureCollection(),
                memoryPool ?? PinnedBlockMemoryPoolFactory.Create(),
                localEndPoint,
                remoteEndPoint);

            http3ConnectionContext.TimeoutControl = timeoutControl;

            return(http3ConnectionContext);
        }
예제 #3
0
        protected async Task InitializeConnectionAsync(RequestDelegate application)
        {
            MultiplexedConnectionContext = new TestMultiplexedConnectionContext(this);

            var httpConnectionContext = new HttpMultiplexedConnectionContext(
                connectionId: "TestConnectionId",
                connectionContext: MultiplexedConnectionContext,
                connectionFeatures: MultiplexedConnectionContext.Features,
                serviceContext: _serviceContext,
                memoryPool: _memoryPool,
                localEndPoint: null,
                remoteEndPoint: null);

            httpConnectionContext.TimeoutControl = _mockTimeoutControl.Object;

            _httpConnection = new HttpConnection(httpConnectionContext);
            _httpConnection.Initialize(Connection);
            _mockTimeoutHandler.Setup(h => h.OnTimeout(It.IsAny <TimeoutReason>()))
            .Callback <TimeoutReason>(r => _httpConnection.OnTimeout(r));

            // ProcessRequestAsync will create the Http3Connection
            _connectionTask = _httpConnection.ProcessRequestsAsync(new DummyApplication(application));

            Connection = (Http3Connection)_httpConnection._requestProcessor;
            Connection._streamLifetimeHandler = new LifetimeHandlerInterceptor(Connection, this);

            await GetInboundControlStream();
        }
예제 #4
0
        public Http3Connection(HttpMultiplexedConnectionContext context)
        {
            _multiplexedContext    = (MultiplexedConnectionContext)context.ConnectionContext;
            _context               = context;
            _streamLifetimeHandler = this;

            _errorCodeFeature = context.ConnectionFeatures.Get <IProtocolErrorCodeFeature>() !;

            var httpLimits = context.ServiceContext.ServerOptions.Limits;

            _serverSettings.HeaderTableSize = (uint)httpLimits.Http3.HeaderTableSize;
            _serverSettings.MaxRequestHeaderFieldSectionSize = (uint)httpLimits.MaxRequestHeadersTotalSize;
        }
예제 #5
0
    public Http3Connection(HttpMultiplexedConnectionContext context)
    {
        _multiplexedContext    = (MultiplexedConnectionContext)context.ConnectionContext;
        _context               = context;
        _streamLifetimeHandler = this;

        _errorCodeFeature = context.ConnectionFeatures.GetRequiredFeature <IProtocolErrorCodeFeature>();

        var httpLimits = context.ServiceContext.ServerOptions.Limits;

        _serverSettings.HeaderTableSize = (uint)httpLimits.Http3.HeaderTableSize;
        _serverSettings.MaxRequestHeaderFieldSectionSize = (uint)httpLimits.MaxRequestHeadersTotalSize;
        _serverSettings.EnableWebTransport = Convert.ToUInt32(context.ServiceContext.ServerOptions.EnableWebTransportAndH3Datagrams);
        // technically these are 2 different settings so they should have separate values but the Chromium implementation requires
        // them to both be 1 to useWebTransport.
        _serverSettings.H3Datagram = Convert.ToUInt32(context.ServiceContext.ServerOptions.EnableWebTransportAndH3Datagrams);
    }
예제 #6
0
    public Task OnConnectionAsync(MultiplexedConnectionContext connectionContext)
    {
        var memoryPoolFeature = connectionContext.Features.Get <IMemoryPoolFeature>();
        var localEndPoint     = connectionContext.LocalEndPoint as IPEndPoint;
        var altSvcHeader      = _addAltSvcHeader && localEndPoint != null?HttpUtilities.GetEndpointAltSvc(localEndPoint, _protocols) : null;

        var httpConnectionContext = new HttpMultiplexedConnectionContext(
            connectionContext.ConnectionId,
            _protocols,
            altSvcHeader,
            connectionContext,
            _serviceContext,
            connectionContext.Features,
            memoryPoolFeature?.MemoryPool ?? System.Buffers.MemoryPool <byte> .Shared,
            localEndPoint,
            connectionContext.RemoteEndPoint as IPEndPoint);

        var connection = new HttpConnection(httpConnectionContext);

        return(connection.ProcessRequestsAsync(_application));
    }