Пример #1
0
        protected override void OnRequestProcessingEnded()
        {
            try
            {
                // https://tools.ietf.org/html/rfc7540#section-8.1
                // If the app finished without reading the request body tell the client not to finish sending it.
                if (!EndStreamReceived && !RstStreamReceived)
                {
                    Log.RequestBodyNotEntirelyRead(ConnectionIdFeature, TraceIdentifier);

                    var states = ApplyCompletionFlag(StreamCompletionFlags.Aborted);
                    if (states.OldState != states.NewState)
                    {
                        // Don't block on IO. This never faults.
                        _ = _http2Output.WriteRstStreamAsync(Http2ErrorCode.NO_ERROR);
                        RequestBodyPipe.Writer.Complete();
                    }
                }

                _http2Output.Dispose();

                RequestBodyPipe.Reader.Complete();

                // The app can no longer read any more of the request body, so return any bytes that weren't read to the
                // connection's flow-control window.
                _inputFlowControl.Abort();

                Reset();
            }
            finally
            {
                _context.StreamLifetimeHandler.OnStreamCompleted(this);
            }
        }
Пример #2
0
        protected override void OnRequestProcessingEnded()
        {
            var states = ApplyCompletionFlag(StreamCompletionFlags.RequestProcessingEnded);

            try
            {
                _http2Output.Dispose();

                RequestBodyPipe.Reader.Complete();

                // The app can no longer read any more of the request body, so return any bytes that weren't read to the
                // connection's flow-control window.
                _inputFlowControl.Abort();

                Reset();
            }
            finally
            {
                TryFireOnStreamCompleted(states);
            }
        }
Пример #3
0
        public void CompleteStream(bool errored)
        {
            try
            {
                // https://tools.ietf.org/html/rfc7540#section-8.1
                // If the app finished without reading the request body tell the client not to finish sending it.
                if (!EndStreamReceived && !RstStreamReceived)
                {
                    if (!errored)
                    {
                        Log.RequestBodyNotEntirelyRead(ConnectionIdFeature, TraceIdentifier);
                    }

                    var(oldState, newState) = ApplyCompletionFlag(StreamCompletionFlags.Aborted);
                    if (oldState != newState)
                    {
                        Debug.Assert(_decrementCalled);

                        // If there was an error starting the stream then we don't want to write RST_STREAM here.
                        // The connection will handle writing RST_STREAM with the correct error code.
                        if (!errored)
                        {
                            // Don't block on IO. This never faults.
                            _ = _http2Output.WriteRstStreamAsync(Http2ErrorCode.NO_ERROR);
                        }
                        RequestBodyPipe.Writer.Complete();
                    }
                }

                _http2Output.Dispose();

                RequestBodyPipe.Reader.Complete();

                // The app can no longer read any more of the request body, so return any bytes that weren't read to the
                // connection's flow-control window.
                _inputFlowControl.Abort();

                Reset();
            }
            finally
            {
                _context.StreamLifetimeHandler.OnStreamCompleted(this);
            }
        }