Exemplo n.º 1
0
        public Http3Stream(Http3StreamContext context)
        {
            Initialize(context);

            InputRemaining = null;

            _context = context;

            _errorCodeFeature = _context.ConnectionFeatures.Get <IProtocolErrorCodeFeature>() !;
            _streamIdFeature  = _context.ConnectionFeatures.Get <IStreamIdFeature>() !;

            _frameWriter = new Http3FrameWriter(
                context.Transport.Output,
                context.StreamContext,
                context.TimeoutControl,
                context.ServiceContext.ServerOptions.Limits.MinResponseDataRate,
                context.ConnectionId,
                context.MemoryPool,
                context.ServiceContext.Log,
                _streamIdFeature,
                context.ClientPeerSettings,
                this);

            // ResponseHeaders aren't set, kind of ugly that we need to reset.
            Reset();

            _http3Output = new Http3OutputProducer(
                _frameWriter,
                context.MemoryPool,
                this,
                context.ServiceContext.Log);
            RequestBodyPipe = CreateRequestBodyPipe(64 * 1024); // windowSize?
            Output          = _http3Output;
            QPackDecoder    = new QPackDecoder(_context.ServiceContext.ServerOptions.Limits.Http3.MaxRequestHeaderFieldSize);
        }
Exemplo n.º 2
0
        public Http3Stream(Http3Connection http3Connection, HttpConnectionContext context)
        {
            Initialize(context);
            // First, determine how we know if an Http3stream is unidirectional or bidirectional
            var httpLimits  = context.ServiceContext.ServerOptions.Limits;
            var http3Limits = httpLimits.Http3;

            _http3Connection = http3Connection;
            _context         = context;

            _frameWriter = new Http3FrameWriter(
                context.Transport.Output,
                context.ConnectionContext,
                context.TimeoutControl,
                httpLimits.MinResponseDataRate,
                context.ConnectionId,
                context.MemoryPool,
                context.ServiceContext.Log);

            // ResponseHeaders aren't set, kind of ugly that we need to reset.
            Reset();

            _http3Output = new Http3OutputProducer(
                _frameWriter,
                context.MemoryPool,
                this,
                context.ServiceContext.Log);
            RequestBodyPipe = CreateRequestBodyPipe(64 * 1024); // windowSize?
            Output          = _http3Output;
            QPackDecoder    = new QPackDecoder(_context.ServiceContext.ServerOptions.Limits.Http3.MaxRequestHeaderFieldSize);
        }
Exemplo n.º 3
0
        private static void TestDecode(byte[] encoded, string expectedHeaderName, string expectedHeaderValue, bool expectDynamicTableEntry, bool byteAtATime)
        {
            var decoder = new QPackDecoder(MaxHeaderFieldSize);
            var handler = new TestHttpHeadersHandler();

            // Read past header
            decoder.Decode(new byte[] { 0x00, 0x00 }, endHeaders: false, handler: handler);

            if (!byteAtATime)
            {
                decoder.Decode(encoded, endHeaders: true, handler: handler);
            }
            else
            {
                // Parse data in 1 byte chunks, separated by empty chunks
                for (int i = 0; i < encoded.Length; i++)
                {
                    bool end = i + 1 == encoded.Length;

                    decoder.Decode(Array.Empty <byte>(), endHeaders: false, handler: handler);
                    decoder.Decode(new byte[] { encoded[i] }, endHeaders: end, handler: handler);
                }
            }

            Assert.Equal(expectedHeaderValue, handler.DecodedHeaders[expectedHeaderName]);
        }
Exemplo n.º 4
0
    public void Initialize(Http3StreamContext context)
    {
        base.Initialize(context);

        InputRemaining = null;

        _context = context;

        _errorCodeFeature   = _context.ConnectionFeatures.GetRequiredFeature <IProtocolErrorCodeFeature>();
        _streamIdFeature    = _context.ConnectionFeatures.GetRequiredFeature <IStreamIdFeature>();
        _streamAbortFeature = _context.ConnectionFeatures.GetRequiredFeature <IStreamAbortFeature>();

        _appCompletedTaskSource.Reset();
        _isClosed = 0;
        _requestHeaderParsingState = default;
        _parsedPseudoHeaderFields  = default;
        _totalParsedHeaderSize     = 0;
        _isMethodConnect           = false;
        _completionState           = default;
        StreamTimeoutTicks         = 0;

        if (_frameWriter == null)
        {
            _frameWriter = new Http3FrameWriter(
                context.StreamContext,
                context.TimeoutControl,
                context.ServiceContext.ServerOptions.Limits.MinResponseDataRate,
                context.MemoryPool,
                context.ServiceContext.Log,
                _streamIdFeature,
                context.ClientPeerSettings,
                this);

            _http3Output = new Http3OutputProducer(
                _frameWriter,
                context.MemoryPool,
                this,
                context.ServiceContext.Log);
            Output          = _http3Output;
            RequestBodyPipe = CreateRequestBodyPipe(64 * 1024); // windowSize?
            QPackDecoder    = new QPackDecoder(_context.ServiceContext.ServerOptions.Limits.Http3.MaxRequestHeaderFieldSize);
        }
        else
        {
            _http3Output.StreamReset();
            RequestBodyPipe.Reset();
            QPackDecoder.Reset();
        }

        _frameWriter.Reset(context.Transport.Output, context.ConnectionId);
    }
Exemplo n.º 5
0
 public QPackDecoderTests()
 {
     _decoder = new QPackDecoder(MaxHeaderFieldSize);
 }