@@ -39,7 +39,7 @@ internal class Http3Connection : ITimeoutHandler
39
39
40
40
private readonly Http3PeerSettings _serverSettings = new Http3PeerSettings ( ) ;
41
41
private readonly StreamCloseAwaitable _streamCompletionAwaitable = new StreamCloseAwaitable ( ) ;
42
-
42
+ private readonly IProtocolErrorCodeFeature _errorCodeFeature ;
43
43
44
44
public Http3Connection ( Http3ConnectionContext context )
45
45
{
@@ -49,6 +49,8 @@ public Http3Connection(Http3ConnectionContext context)
49
49
_timeoutControl = new TimeoutControl ( this ) ;
50
50
_context . TimeoutControl ??= _timeoutControl ;
51
51
52
+ _errorCodeFeature = context . ConnectionFeatures . Get < IProtocolErrorCodeFeature > ( ) ! ;
53
+
52
54
var httpLimits = context . ServiceContext . ServerOptions . Limits ;
53
55
54
56
_serverSettings . HeaderTableSize = ( uint ) httpLimits . Http3 . HeaderTableSize ;
@@ -76,6 +78,7 @@ internal long HighestStreamId
76
78
public Http3ControlStream ? ControlStream { get ; set ; }
77
79
public Http3ControlStream ? EncoderStream { get ; set ; }
78
80
public Http3ControlStream ? DecoderStream { get ; set ; }
81
+ public string ConnectionId => _context . ConnectionId ;
79
82
80
83
public async Task ProcessStreamsAsync < TContext > ( IHttpApplication < TContext > httpApplication ) where TContext : notnull
81
84
{
@@ -163,7 +166,7 @@ private bool TryClose()
163
166
return false ;
164
167
}
165
168
166
- public void Abort ( ConnectionAbortedException ex )
169
+ public void Abort ( ConnectionAbortedException ex , Http3ErrorCode errorCode )
167
170
{
168
171
bool previousState ;
169
172
@@ -180,6 +183,7 @@ public void Abort(ConnectionAbortedException ex)
180
183
SendGoAway ( _highestOpenedStreamId ) ;
181
184
}
182
185
186
+ _errorCodeFeature . Error = ( long ) errorCode ;
183
187
_multiplexedContext . Abort ( ex ) ;
184
188
}
185
189
}
@@ -326,9 +330,8 @@ internal async Task InnerProcessStreamsAsync<TContext>(IHttpApplication<TContext
326
330
Log . RequestProcessingError ( _context . ConnectionId , ex ) ;
327
331
error = ex ;
328
332
}
329
- catch ( Http3ConnectionException ex )
333
+ catch ( Http3ConnectionErrorException ex )
330
334
{
331
- // TODO Connection error code?
332
335
Log . Http3ConnectionError ( _context . ConnectionId , ex ) ;
333
336
error = ex ;
334
337
}
@@ -352,7 +355,7 @@ internal async Task InnerProcessStreamsAsync<TContext>(IHttpApplication<TContext
352
355
353
356
foreach ( var stream in _streams . Values )
354
357
{
355
- stream . Abort ( connectionError ) ;
358
+ stream . Abort ( connectionError , ( Http3ErrorCode ) _errorCodeFeature . Error ) ;
356
359
}
357
360
358
361
while ( _activeRequestCount > 0 )
@@ -364,7 +367,7 @@ internal async Task InnerProcessStreamsAsync<TContext>(IHttpApplication<TContext
364
367
}
365
368
catch
366
369
{
367
- Abort ( connectionError ) ;
370
+ Abort ( connectionError , Http3ErrorCode . NoError ) ;
368
371
throw ;
369
372
}
370
373
}
0 commit comments