@@ -47,6 +47,7 @@ public async Task CanReadFromContentLength(HttpVersion httpVersion)
47
47
count = stream . Read ( buffer , 0 , buffer . Length ) ;
48
48
Assert . Equal ( 0 , count ) ;
49
49
50
+ input . Http1Connection . RequestBodyPipe . Reader . Complete ( ) ;
50
51
await body . StopAsync ( ) ;
51
52
}
52
53
}
@@ -73,6 +74,7 @@ public async Task CanReadAsyncFromContentLength(HttpVersion httpVersion)
73
74
count = await stream . ReadAsync ( buffer , 0 , buffer . Length ) ;
74
75
Assert . Equal ( 0 , count ) ;
75
76
77
+ input . Http1Connection . RequestBodyPipe . Reader . Complete ( ) ;
76
78
await body . StopAsync ( ) ;
77
79
}
78
80
}
@@ -101,6 +103,7 @@ public async Task CanReadFromChunkedEncoding()
101
103
count = stream . Read ( buffer , 0 , buffer . Length ) ;
102
104
Assert . Equal ( 0 , count ) ;
103
105
106
+ input . Http1Connection . RequestBodyPipe . Reader . Complete ( ) ;
104
107
await body . StopAsync ( ) ;
105
108
}
106
109
}
@@ -127,6 +130,7 @@ public async Task CanReadAsyncFromChunkedEncoding()
127
130
count = await stream . ReadAsync ( buffer , 0 , buffer . Length ) ;
128
131
Assert . Equal ( 0 , count ) ;
129
132
133
+ input . Http1Connection . RequestBodyPipe . Reader . Complete ( ) ;
130
134
await body . StopAsync ( ) ;
131
135
}
132
136
}
@@ -152,6 +156,7 @@ public async Task ReadExitsGivenIncompleteChunkedExtension()
152
156
Assert . Equal ( 5 , await readTask . DefaultTimeout ( ) ) ;
153
157
Assert . Equal ( 0 , await stream . ReadAsync ( buffer , 0 , buffer . Length ) ) ;
154
158
159
+ input . Http1Connection . RequestBodyPipe . Reader . Complete ( ) ;
155
160
await body . StopAsync ( ) ;
156
161
}
157
162
}
@@ -173,6 +178,7 @@ public async Task ReadThrowsGivenChunkPrefixGreaterThanMaxInt()
173
178
Assert . IsType < OverflowException > ( ex . InnerException ) ;
174
179
Assert . Equal ( CoreStrings . BadRequest_BadChunkSizeData , ex . Message ) ;
175
180
181
+ input . Http1Connection . RequestBodyPipe . Reader . Complete ( ) ;
176
182
await body . StopAsync ( ) ;
177
183
}
178
184
}
@@ -194,6 +200,7 @@ public async Task ReadThrowsGivenChunkPrefixGreaterThan8Bytes()
194
200
195
201
Assert . Equal ( CoreStrings . BadRequest_BadChunkSizeData , ex . Message ) ;
196
202
203
+ input . Http1Connection . RequestBodyPipe . Reader . Complete ( ) ;
197
204
await body . StopAsync ( ) ;
198
205
}
199
206
}
@@ -221,6 +228,7 @@ public async Task CanReadFromRemainingData(HttpVersion httpVersion)
221
228
222
229
input . Fin ( ) ;
223
230
231
+ input . Http1Connection . RequestBodyPipe . Reader . Complete ( ) ;
224
232
await body . StopAsync ( ) ;
225
233
}
226
234
}
@@ -246,6 +254,7 @@ public async Task CanReadAsyncFromRemainingData(HttpVersion httpVersion)
246
254
247
255
input . Fin ( ) ;
248
256
257
+ input . Http1Connection . RequestBodyPipe . Reader . Complete ( ) ;
249
258
await body . StopAsync ( ) ;
250
259
}
251
260
}
@@ -316,6 +325,7 @@ public async Task CanHandleLargeBlocks()
316
325
Assert . Equal ( 8197 , requestArray . Length ) ;
317
326
AssertASCII ( largeInput + "Hello" , new ArraySegment < byte > ( requestArray , 0 , requestArray . Length ) ) ;
318
327
328
+ input . Http1Connection . RequestBodyPipe . Reader . Complete ( ) ;
319
329
await body . StopAsync ( ) ;
320
330
}
321
331
}
@@ -381,6 +391,7 @@ public async Task CopyToAsyncDoesNotCompletePipeReader()
381
391
382
392
Assert . Equal ( 0 , await body . ReadAsync ( new ArraySegment < byte > ( new byte [ 1 ] ) ) ) ;
383
393
394
+ input . Http1Connection . RequestBodyPipe . Reader . Complete ( ) ;
384
395
await body . StopAsync ( ) ;
385
396
}
386
397
}
@@ -398,6 +409,7 @@ public async Task ConsumeAsyncConsumesAllRemainingInput()
398
409
399
410
Assert . Equal ( 0 , await body . ReadAsync ( new ArraySegment < byte > ( new byte [ 1 ] ) ) ) ;
400
411
412
+ input . Http1Connection . RequestBodyPipe . Reader . Complete ( ) ;
401
413
await body . StopAsync ( ) ;
402
414
}
403
415
}
@@ -494,6 +506,7 @@ public async Task ConnectionUpgradeKeepAlive(string headerConnection)
494
506
495
507
input . Fin ( ) ;
496
508
509
+ input . Http1Connection . RequestBodyPipe . Reader . Complete ( ) ;
497
510
await body . StopAsync ( ) ;
498
511
}
499
512
}
@@ -520,6 +533,7 @@ public async Task UpgradeConnectionAcceptsContentLengthZero()
520
533
521
534
input . Fin ( ) ;
522
535
536
+ input . Http1Connection . RequestBodyPipe . Reader . Complete ( ) ;
523
537
await body . StopAsync ( ) ;
524
538
}
525
539
}
@@ -543,34 +557,11 @@ public async Task PumpAsyncDoesNotReturnAfterCancelingInput()
543
557
input . Add ( "b" ) ;
544
558
Assert . Equal ( 1 , await stream . ReadAsync ( new byte [ 1 ] , 0 , 1 ) ) ;
545
559
560
+ input . Http1Connection . RequestBodyPipe . Reader . Complete ( ) ;
546
561
await body . StopAsync ( ) ;
547
562
}
548
563
}
549
564
550
- [ Fact ]
551
- public async Task StopAsyncPreventsFurtherDataConsumption ( )
552
- {
553
- using ( var input = new TestInput ( ) )
554
- {
555
- var body = Http1MessageBody . For ( HttpVersion . Http11 , new HttpRequestHeaders { HeaderContentLength = "2" } , input . Http1Connection ) ;
556
- var stream = new HttpRequestStream ( Mock . Of < IHttpBodyControlFeature > ( ) ) ;
557
- stream . StartAcceptingReads ( body ) ;
558
-
559
- // Add some input and consume it to ensure PumpAsync is running
560
- input . Add ( "a" ) ;
561
- Assert . Equal ( 1 , await stream . ReadAsync ( new byte [ 1 ] , 0 , 1 ) ) ;
562
-
563
- await body . StopAsync ( ) ;
564
-
565
- // Add some more data. Checking for cancellation and exiting the loop
566
- // should take priority over reading this data.
567
- input . Add ( "b" ) ;
568
-
569
- // There shouldn't be any additional data available
570
- Assert . Equal ( 0 , await stream . ReadAsync ( new byte [ 1 ] , 0 , 1 ) ) ;
571
- }
572
- }
573
-
574
565
[ Fact ]
575
566
public async Task ReadAsyncThrowsOnTimeout ( )
576
567
{
@@ -592,6 +583,7 @@ public async Task ReadAsyncThrowsOnTimeout()
592
583
var exception = await Assert . ThrowsAsync < BadHttpRequestException > ( async ( ) => await body . ReadAsync ( new Memory < byte > ( new byte [ 1 ] ) ) ) ;
593
584
Assert . Equal ( StatusCodes . Status408RequestTimeout , exception . StatusCode ) ;
594
585
586
+ input . Http1Connection . RequestBodyPipe . Reader . Complete ( ) ;
595
587
await body . StopAsync ( ) ;
596
588
}
597
589
}
@@ -622,6 +614,7 @@ public async Task ConsumeAsyncCompletesAndDoesNotThrowOnTimeout()
622
614
It . IsAny < string > ( ) ,
623
615
It . Is < BadHttpRequestException > ( ex => ex . Reason == RequestRejectionReason . RequestBodyTimeout ) ) ) ;
624
616
617
+ input . Http1Connection . RequestBodyPipe . Reader . Complete ( ) ;
625
618
await body . StopAsync ( ) ;
626
619
}
627
620
}
@@ -650,6 +643,7 @@ public async Task CopyToAsyncThrowsOnTimeout()
650
643
Assert . Equal ( StatusCodes . Status408RequestTimeout , exception . StatusCode ) ;
651
644
}
652
645
646
+ input . Http1Connection . RequestBodyPipe . Reader . Complete ( ) ;
653
647
await body . StopAsync ( ) ;
654
648
}
655
649
}
@@ -676,6 +670,7 @@ public async Task LogsWhenStartsReadingRequestBody()
676
670
677
671
input . Fin ( ) ;
678
672
673
+ input . Http1Connection . RequestBodyPipe . Reader . Complete ( ) ;
679
674
await body . StopAsync ( ) ;
680
675
}
681
676
}
@@ -706,6 +701,7 @@ public async Task LogsWhenStopsReadingRequestBody()
706
701
707
702
await logEvent . Task . DefaultTimeout ( ) ;
708
703
704
+ input . Http1Connection . RequestBodyPipe . Reader . Complete ( ) ;
709
705
await body . StopAsync ( ) ;
710
706
}
711
707
}
@@ -765,6 +761,7 @@ public async Task OnlyEnforcesRequestBodyTimeoutAfterSending100Continue()
765
761
input . Add ( "a" ) ;
766
762
await readTask ;
767
763
764
+ input . Http1Connection . RequestBodyPipe . Reader . Complete ( ) ;
768
765
await body . StopAsync ( ) ;
769
766
}
770
767
}
@@ -797,6 +794,7 @@ public async Task DoesNotEnforceRequestBodyTimeoutOnUpgradeRequests()
797
794
mockTimeoutControl . Verify ( timeoutControl => timeoutControl . PauseTimingReads ( ) , Times . Never ) ;
798
795
mockTimeoutControl . Verify ( timeoutControl => timeoutControl . ResumeTimingReads ( ) , Times . Never ) ;
799
796
797
+ input . Http1Connection . RequestBodyPipe . Reader . Complete ( ) ;
800
798
await body . StopAsync ( ) ;
801
799
}
802
800
}
0 commit comments