Example #1
0
    public void Abort(ConnectionAbortedException abortReason, Http3ErrorCode errorCode)
    {
        // TODO - Should there be a check here to track abort state to avoid
        // running twice for a request?

        Log.Http3StreamAbort(_context.ConnectionId, errorCode, abortReason);

        _errorCodeFeature.Error = (long)errorCode;
        _frameWriter.Abort(abortReason);

        Input.Complete(abortReason);
    }
Example #2
0
    private void AbortCore(Exception exception, Http3ErrorCode errorCode)
    {
        lock (_completionLock)
        {
            if (IsCompleted)
            {
                return;
            }

            var(oldState, newState) = ApplyCompletionFlag(StreamCompletionFlags.Aborted);

            if (oldState == newState)
            {
                return;
            }

            if (!(exception is ConnectionAbortedException abortReason))
            {
                abortReason = new ConnectionAbortedException(exception.Message, exception);
            }

            Log.Http3StreamAbort(TraceIdentifier, errorCode, abortReason);

            // Call _http3Output.Stop() prior to poisoning the request body stream or pipe to
            // ensure that an app that completes early due to the abort doesn't result in header frames being sent.
            _http3Output.Stop();

            CancelRequestAbortedToken();

            // Unblock the request body.
            PoisonBody(exception);
            RequestBodyPipe.Writer.Complete(exception);

            // Abort framewriter and underlying transport after stopping output.
            _errorCodeFeature.Error = (long)errorCode;
            _frameWriter.Abort(abortReason);
        }
    }