@@ -4751,6 +4751,52 @@ await ExpectAsync(Http2FrameType.DATA,
4751
4751
Assert . True ( _helloWorldBytes . AsSpan ( 9 , 3 ) . SequenceEqual ( dataFrame3 . PayloadSequence . ToArray ( ) ) ) ;
4752
4752
}
4753
4753
4754
+ [ Fact ]
4755
+ public async Task WINDOW_UPDATE_Received_OnStream_Resumed_WhenInitialWindowSizeNegativeMidStream ( )
4756
+ {
4757
+ const int windowSize = 3 ;
4758
+ _clientSettings . InitialWindowSize = windowSize ;
4759
+ var tcs = new TaskCompletionSource ( TaskCreationOptions . RunContinuationsAsynchronously ) ;
4760
+ await InitializeConnectionAsync ( async context =>
4761
+ {
4762
+ var bodyControlFeature = context . Features . Get < IHttpBodyControlFeature > ( ) ;
4763
+ bodyControlFeature . AllowSynchronousIO = true ;
4764
+ await context . Response . Body . WriteAsync ( new byte [ windowSize - 1 ] , 0 , windowSize - 1 ) ;
4765
+ await tcs . Task ;
4766
+ await context . Response . Body . WriteAsync ( new byte [ windowSize ] , 0 , windowSize ) ;
4767
+ } ) ;
4768
+ await StartStreamAsync ( 1 , _browserRequestHeaders , endStream : true ) ;
4769
+ await ExpectAsync ( Http2FrameType . HEADERS ,
4770
+ withLength : 32 ,
4771
+ withFlags : ( byte ) Http2HeadersFrameFlags . END_HEADERS ,
4772
+ withStreamId : 1 ) ;
4773
+
4774
+ // Decrease window size after server has already sent the current window - 1 size of data
4775
+ _clientSettings . InitialWindowSize = windowSize - 2 ;
4776
+ await SendSettingsAsync ( ) ;
4777
+ await ExpectAsync ( Http2FrameType . DATA ,
4778
+ withLength : windowSize - 1 ,
4779
+ withFlags : ( byte ) Http2DataFrameFlags . NONE ,
4780
+ withStreamId : 1 ) ;
4781
+ await ExpectAsync ( Http2FrameType . SETTINGS ,
4782
+ withLength : 0 ,
4783
+ withFlags : ( byte ) Http2DataFrameFlags . END_STREAM ,
4784
+ withStreamId : 0 ) ;
4785
+ tcs . SetResult ( ) ;
4786
+
4787
+ // send window update to receive the next frame data
4788
+ await SendWindowUpdateAsync ( 1 , windowSize + 1 ) ;
4789
+ await ExpectAsync ( Http2FrameType . DATA ,
4790
+ withLength : windowSize ,
4791
+ withFlags : ( byte ) Http2DataFrameFlags . NONE ,
4792
+ withStreamId : 1 ) ;
4793
+ await ExpectAsync ( Http2FrameType . DATA ,
4794
+ withLength : 0 ,
4795
+ withFlags : ( byte ) Http2DataFrameFlags . END_STREAM ,
4796
+ withStreamId : 1 ) ;
4797
+ await StopConnectionAsync ( expectedLastStreamId : 1 , ignoreNonGoAwayFrames : false ) ;
4798
+ }
4799
+
4754
4800
[ Fact ]
4755
4801
public async Task CONTINUATION_Received_Decoded ( )
4756
4802
{
0 commit comments