@@ -155,7 +155,6 @@ await InitializeConnectionAsync(async context =>
155
155
[ QuarantinedTest ( "https://github.com/dotnet/aspnetcore/issues/42133" ) ]
156
156
public async Task HEADERS_Received_SecondRequest_Accepted ( )
157
157
{
158
- // Add stream to Http2Connection._completedStreams inline with SetResult().
159
158
var appDelegateTcs = new TaskCompletionSource ( ) ;
160
159
await InitializeConnectionAsync ( async context =>
161
160
{
@@ -181,6 +180,19 @@ await InitializeConnectionAsync(async context =>
181
180
await appDelegateTcs . Task ;
182
181
} ) ;
183
182
183
+ var originalHandler = _connection . _streamLifetimeHandler ;
184
+ var tcs = new TaskCompletionSource ( ) ;
185
+ var streamLifetimeHandler = new Mock < IHttp2StreamLifetimeHandler > ( ) ;
186
+ streamLifetimeHandler . Setup ( o => o . OnStreamCompleted ( It . IsAny < Http2Stream > ( ) ) ) . Callback ( ( Http2Stream stream ) =>
187
+ {
188
+ // Add stream to Http2Connection._completedStreams.
189
+ originalHandler . OnStreamCompleted ( stream ) ;
190
+
191
+ // Unblock test code that will call TriggerTick and return the stream to the pool
192
+ tcs . TrySetResult ( ) ;
193
+ } ) ;
194
+ _connection . _streamLifetimeHandler = streamLifetimeHandler . Object ;
195
+
184
196
// HEADERS + END_HEADERS
185
197
// :method = CONNECT
186
198
// :protocol = websocket
@@ -224,6 +236,7 @@ await InitializeConnectionAsync(async context =>
224
236
Assert . Equal ( 0x01 , dataFrame . Payload . Span [ 0 ] ) ;
225
237
226
238
appDelegateTcs . TrySetResult ( ) ;
239
+ await tcs . Task . DefaultTimeout ( ) ;
227
240
228
241
dataFrame = await ExpectAsync ( Http2FrameType . DATA ,
229
242
withLength : 0 ,
@@ -595,8 +608,23 @@ await InitializeConnectionAsync(async context =>
595
608
// We've done the test. Now just return the normal echo server behavior.
596
609
await _echoApplication ( context ) ;
597
610
}
611
+ } ) ;
598
612
613
+ var originalHandler = _connection . _streamLifetimeHandler ;
614
+ var tcs = new TaskCompletionSource ( ) ;
615
+ var streamLifetimeHandler = new Mock < IHttp2StreamLifetimeHandler > ( ) ;
616
+ streamLifetimeHandler . Setup ( o => o . OnStreamCompleted ( It . IsAny < Http2Stream > ( ) ) ) . Callback ( ( Http2Stream stream ) =>
617
+ {
618
+ // Add stream to Http2Connection._completedStreams.
619
+ originalHandler . OnStreamCompleted ( stream ) ;
620
+
621
+ if ( requestCount == 1 )
622
+ {
623
+ // Unblock test code that will call TriggerTick and return the stream to the pool
624
+ tcs . TrySetResult ( ) ;
625
+ }
599
626
} ) ;
627
+ _connection . _streamLifetimeHandler = streamLifetimeHandler . Object ;
600
628
601
629
// HEADERS + END_HEADERS
602
630
// :method = CONNECT
@@ -636,6 +664,8 @@ await InitializeConnectionAsync(async context =>
636
664
Assert . Equal ( 0x01 , dataFrame . Payload . Span [ 0 ] ) ;
637
665
638
666
appDelegateTcs . TrySetResult ( ) ;
667
+ await tcs . Task . DefaultTimeout ( ) ;
668
+
639
669
dataFrame = await ExpectAsync ( Http2FrameType . DATA ,
640
670
withLength : 0 ,
641
671
withFlags : ( byte ) Http2DataFrameFlags . END_STREAM ,
0 commit comments