Example #1
0
        public async Task ProcessRequestAsync <TContext>(IHttpApplication <TContext> application) where TContext : notnull
        {
            try
            {
                var streamType = await TryReadStreamIdAsync();

                if (streamType == -1)
                {
                    return;
                }

                if (streamType == ControlStream)
                {
                    if (!_http3Connection.SetInboundControlStream(this))
                    {
                        // https://quicwg.org/base-drafts/draft-ietf-quic-http.html#section-6.2.1
                        throw new Http3ConnectionErrorException(CoreStrings.FormatHttp3ControlStreamErrorMultipleInboundStreams("control"), Http3ErrorCode.StreamCreationError);
                    }

                    await HandleControlStream();
                }
                else if (streamType == EncoderStream)
                {
                    if (!_http3Connection.SetInboundEncoderStream(this))
                    {
                        // https://quicwg.org/base-drafts/draft-ietf-quic-qpack.html#section-4.2
                        throw new Http3ConnectionErrorException(CoreStrings.FormatHttp3ControlStreamErrorMultipleInboundStreams("encoder"), Http3ErrorCode.StreamCreationError);
                    }

                    await HandleEncodingDecodingTask();
                }
                else if (streamType == DecoderStream)
                {
                    if (!_http3Connection.SetInboundDecoderStream(this))
                    {
                        // https://quicwg.org/base-drafts/draft-ietf-quic-qpack.html#section-4.2
                        throw new Http3ConnectionErrorException(CoreStrings.FormatHttp3ControlStreamErrorMultipleInboundStreams("decoder"), Http3ErrorCode.StreamCreationError);
                    }
                    await HandleEncodingDecodingTask();
                }
                else
                {
                    // TODO Close the control stream as it's unexpected.
                }
            }
            catch (Http3ConnectionErrorException ex)
            {
                Log.Http3ConnectionError(_http3Connection.ConnectionId, ex);
                _http3Connection.Abort(new ConnectionAbortedException(ex.Message, ex), ex.ErrorCode);
            }
        }
Example #2
0
        public async Task ProcessRequestAsync <TContext>(IHttpApplication <TContext> application) where TContext : notnull
        {
            var streamType = await TryReadStreamIdAsync();

            if (streamType == -1)
            {
                return;
            }

            if (streamType == ControlStream)
            {
                if (!_http3Connection.SetInboundControlStream(this))
                {
                    // TODO propagate these errors to connection.
                    throw new Http3ConnectionException("HTTP_STREAM_CREATION_ERROR");
                }

                await HandleControlStream();
            }
            else if (streamType == EncoderStream)
            {
                if (!_http3Connection.SetInboundEncoderStream(this))
                {
                    throw new Http3ConnectionException("HTTP_STREAM_CREATION_ERROR");
                }

                await HandleEncodingDecodingTask();
            }
            else if (streamType == DecoderStream)
            {
                if (!_http3Connection.SetInboundDecoderStream(this))
                {
                    throw new Http3ConnectionException("HTTP_STREAM_CREATION_ERROR");
                }
                await HandleEncodingDecodingTask();
            }
            else
            {
                // TODO Close the control stream as it's unexpected.
            }
        }