Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/Servers/Kestrel/Core/src/Internal/Http3/Http3Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -505,12 +505,14 @@ public async Task ProcessRequestsAsync<TContext>(IHttpApplication<TContext> appl
}
}

var errorCode = GetErrorCodeOrNoError();

// Abort active request streams.
lock (_streams)
{
foreach (var stream in _streams.Values)
{
stream.Abort(CreateConnectionAbortError(error, clientAbort), (Http3ErrorCode)_errorCodeFeature.Error);
stream.Abort(CreateConnectionAbortError(error, clientAbort), errorCode);
}
}

Expand Down Expand Up @@ -546,7 +548,7 @@ public async Task ProcessRequestsAsync<TContext>(IHttpApplication<TContext> appl
}

// Complete
Abort(CreateConnectionAbortError(error, clientAbort), (Http3ErrorCode)_errorCodeFeature.Error, reason);
Abort(CreateConnectionAbortError(error, clientAbort), errorCode, reason);

// Wait for active requests to complete.
while (_activeRequestCount > 0)
Expand Down Expand Up @@ -905,7 +907,7 @@ public void OnInputOrOutputCompleted()
TryStopAcceptingStreams();

// Abort the connection using the error code the client used. For a graceful close, this should be H3_NO_ERROR.
Abort(new ConnectionAbortedException(CoreStrings.ConnectionAbortedByClient), (Http3ErrorCode)_errorCodeFeature.Error, ConnectionEndReason.TransportCompleted);
Abort(new ConnectionAbortedException(CoreStrings.ConnectionAbortedByClient), GetErrorCodeOrNoError(), ConnectionEndReason.TransportCompleted);
}

internal WebTransportSession OpenNewWebTransportSession(Http3Stream http3Stream)
Expand All @@ -923,6 +925,11 @@ internal WebTransportSession OpenNewWebTransportSession(Http3Stream http3Stream)
return session;
}

private Http3ErrorCode GetErrorCodeOrNoError()
{
return _errorCodeFeature.Error <= 0 ? Http3ErrorCode.NoError : (Http3ErrorCode)_errorCodeFeature.Error;
}

private static class GracefulCloseInitiator
{
public const int None = 0;
Expand Down