@@ -505,12 +505,14 @@ public async Task ProcessRequestsAsync<TContext>(IHttpApplication<TContext> appl
505505 }
506506 }
507507
508+ var errorCode = GetErrorCodeOrNoError ( ) ;
509+
508510 // Abort active request streams.
509511 lock ( _streams )
510512 {
511513 foreach ( var stream in _streams . Values )
512514 {
513- stream . Abort ( CreateConnectionAbortError ( error , clientAbort ) , ( Http3ErrorCode ) _errorCodeFeature . Error ) ;
515+ stream . Abort ( CreateConnectionAbortError ( error , clientAbort ) , errorCode ) ;
514516 }
515517 }
516518
@@ -546,7 +548,6 @@ public async Task ProcessRequestsAsync<TContext>(IHttpApplication<TContext> appl
546548 }
547549
548550 // Complete
549- var errorCode = _errorCodeFeature . Error == - 1 ? Http3ErrorCode . NoError : ( Http3ErrorCode ) _errorCodeFeature . Error ;
550551 Abort ( CreateConnectionAbortError ( error , clientAbort ) , errorCode , reason ) ;
551552
552553 // Wait for active requests to complete.
@@ -906,7 +907,7 @@ public void OnInputOrOutputCompleted()
906907 TryStopAcceptingStreams ( ) ;
907908
908909 // Abort the connection using the error code the client used. For a graceful close, this should be H3_NO_ERROR.
909- Abort ( new ConnectionAbortedException ( CoreStrings . ConnectionAbortedByClient ) , ( Http3ErrorCode ) _errorCodeFeature . Error , ConnectionEndReason . TransportCompleted ) ;
910+ Abort ( new ConnectionAbortedException ( CoreStrings . ConnectionAbortedByClient ) , GetErrorCodeOrNoError ( ) , ConnectionEndReason . TransportCompleted ) ;
910911 }
911912
912913 internal WebTransportSession OpenNewWebTransportSession ( Http3Stream http3Stream )
@@ -924,6 +925,11 @@ internal WebTransportSession OpenNewWebTransportSession(Http3Stream http3Stream)
924925 return session ;
925926 }
926927
928+ private Http3ErrorCode GetErrorCodeOrNoError ( )
929+ {
930+ return _errorCodeFeature . Error <= 0 ? Http3ErrorCode . NoError : ( Http3ErrorCode ) _errorCodeFeature . Error ;
931+ }
932+
927933 private static class GracefulCloseInitiator
928934 {
929935 public const int None = 0 ;
0 commit comments