This repository was archived by the owner on Dec 18, 2018. It is now read-only.
File tree 2 files changed +49
-0
lines changed
src/Microsoft.AspNet.Server.Kestrel/Http
test/Microsoft.AspNet.Server.KestrelTests 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -196,6 +196,9 @@ public async Task RequestProcessingAsync()
196
196
await FireOnCompleted ( ) ;
197
197
198
198
await ProduceEnd ( ) ;
199
+
200
+ // Finish reading the request body in case the app did not.
201
+ await RequestBody . CopyToAsync ( Stream . Null ) ;
199
202
}
200
203
201
204
terminated = ! _keepAlive ;
Original file line number Diff line number Diff line change @@ -876,6 +876,52 @@ await connection.ReceiveEnd(
876
876
}
877
877
}
878
878
879
+ [ Theory ]
880
+ [ MemberData ( nameof ( ConnectionFilterData ) ) ]
881
+ public async Task RequestBodyIsConsumedAutomaticallyIfAppDoesntConsumeItFully ( ServiceContext testContext )
882
+ {
883
+ using ( var server = new TestServer ( async frame =>
884
+ {
885
+ var response = frame . Get < IHttpResponseFeature > ( ) ;
886
+ var request = frame . Get < IHttpRequestFeature > ( ) ;
887
+
888
+ Assert . Equal ( "POST" , request . Method ) ;
889
+
890
+ response . Headers . Clear ( ) ;
891
+ response . Headers [ "Content-Length" ] = new [ ] { "11" } ;
892
+
893
+ await response . Body . WriteAsync ( Encoding . ASCII . GetBytes ( "Hello World" ) , 0 , 11 ) ;
894
+ } , testContext ) )
895
+ {
896
+ using ( var connection = new TestConnection ( ) )
897
+ {
898
+ await connection . SendEnd (
899
+ "POST / HTTP/1.1" ,
900
+ "Content-Length: 5" ,
901
+ "" ,
902
+ "HelloPOST / HTTP/1.1" ,
903
+ "Transfer-Encoding: chunked" ,
904
+ "" ,
905
+ "C" , "HelloChunked" , "0" ,
906
+ "POST / HTTP/1.1" ,
907
+ "Content-Length: 7" ,
908
+ "" ,
909
+ "Goodbye" ) ;
910
+ await connection . ReceiveEnd (
911
+ "HTTP/1.1 200 OK" ,
912
+ "Content-Length: 11" ,
913
+ "" ,
914
+ "Hello WorldHTTP/1.1 200 OK" ,
915
+ "Content-Length: 11" ,
916
+ "" ,
917
+ "Hello WorldHTTP/1.1 200 OK" ,
918
+ "Content-Length: 11" ,
919
+ "" ,
920
+ "Hello World" ) ;
921
+ }
922
+ }
923
+ }
924
+
879
925
private class TestApplicationErrorLogger : ILogger
880
926
{
881
927
public int ApplicationErrorsLogged { get ; set ; }
You can’t perform that action at this time.
0 commit comments