Exemplo n.º 1
0
        private void ProcessDataFrame(FrameHeader frameHeader)
        {
            Debug.Assert(frameHeader.Type == FrameType.Data);

            Http2Stream http2Stream = GetStream(frameHeader.StreamId);

            if (http2Stream == null)
            {
                _incomingBuffer.Discard(frameHeader.Length);

                // Don't wait for completion, which could happen asynchronously.
                ValueTask ignored = SendRstStreamAsync(frameHeader.StreamId, Http2ProtocolErrorCode.StreamClosed);
                return;
            }

            ReadOnlySpan <byte> frameData = GetFrameData(_incomingBuffer.ActiveSpan.Slice(0, frameHeader.Length), hasPad: frameHeader.PaddedFlag, hasPriority: false);

            bool endStream = frameHeader.EndStreamFlag;

            http2Stream.OnResponseData(frameData, endStream);

            _incomingBuffer.Discard(frameHeader.Length);

            if (endStream)
            {
                RemoveStream(http2Stream);
            }
        }
Exemplo n.º 2
0
        private Task ProcessDataFrame(FrameHeader frameHeader)
        {
            Debug.Assert(frameHeader.Type == FrameType.Data);

            Http2Stream http2Stream = GetStream(frameHeader.StreamId);

            if (http2Stream == null)
            {
                _incomingBuffer.Discard(frameHeader.Length);
                return(SendRstStreamFrameAsync(frameHeader.StreamId, Http2ProtocolErrorCode.StreamClosed));
            }

            ReadOnlySpan <byte> frameData = GetFrameData(_incomingBuffer.ActiveSpan.Slice(0, frameHeader.Length), hasPad: frameHeader.PaddedFlag, hasPriority: false);

            bool endStream = frameHeader.EndStreamFlag;

            http2Stream.OnResponseData(frameData, endStream);

            _incomingBuffer.Discard(frameHeader.Length);

            if (endStream)
            {
                RemoveStream(http2Stream);
            }

            return(Task.CompletedTask);
        }
Exemplo n.º 3
0
        private void ProcessDataFrame(FrameHeader frameHeader)
        {
            Debug.Assert(frameHeader.Type == FrameType.Data);

            Http2Stream http2Stream = GetStream(frameHeader.StreamId);

            if (http2Stream == null)
            {
                _incomingBuffer.Discard(frameHeader.Length);

                throw new Http2ProtocolException(Http2ProtocolErrorCode.StreamClosed);
            }

            ReadOnlySpan <byte> frameData = GetFrameData(_incomingBuffer.ActiveSpan.Slice(0, frameHeader.Length), hasPad: frameHeader.PaddedFlag, hasPriority: false);

            bool endStream = frameHeader.EndStreamFlag;

            http2Stream.OnResponseData(frameData, endStream);

            _incomingBuffer.Discard(frameHeader.Length);

            if (endStream)
            {
                RemoveStream(http2Stream);
            }
        }