1 override of Body
Microsoft.AspNetCore.Http (1)
Internal\DefaultHttpRequest.cs (1)
91public override Stream Body
214 writes to Body
BasicWebSite (2)
StartupRequestLimitSize.cs (1)
27httpContext.Request.Body = new RequestBodySizeCheckingStream(
StartupWhereReadingRequestBodyThrows.cs (1)
23context.Request.Body = new ThrowingStream();
InMemory.FunctionalTests (2)
RequestTests.cs (2)
42context.Request.Body = new MemoryStream(); 95context.Request.Body = mockStream.Object;
InProcessWebSite (1)
src\Servers\IIS\IIS\test\testassets\InProcessWebSite\Startup.cs (1)
307ctx.Request.Body = body;
Microsoft.AspNetCore.Components.Server.Tests (4)
CircuitDisconnectMiddlewareTest.cs (4)
123context.Request.Body = memory; 156context.Request.Body = memory; 193context.Request.Body = memory; 231context.Request.Body = memory;
Microsoft.AspNetCore.Grpc.JsonTranscoding.Tests (16)
UnaryServerCallHandlerTests.cs (16)
201httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(JsonFormatter.Default.Format(new HelloRequest 239httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(JsonFormatter.Default.Format(new HelloRequest.Types.SubMessage 289httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(sw.ToString())); 339httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(sw.ToString())); 389httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(sw.ToString())); 439httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(sw.ToString())); 489httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(sw.ToString())); 739httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(json)); 777httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(json)); 806httpContext.Request.Body = new MemoryStream("{}"u8.ToArray()); 1141httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(requestContent)); 1191httpContext.Request.Body = new MemoryStream(requestContent); 1228httpContext.Request.Body = new MemoryStream("null"u8.ToArray()); 1263httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(requestJson)); 1324httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(requestContent)); 1723httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(requestJson));
Microsoft.AspNetCore.Http (1)
Internal\BufferingHelper.cs (1)
21request.Body = fileStream;
Microsoft.AspNetCore.Http.Connections.Tests (8)
HttpConnectionDispatcherTests.cs (8)
220context.Request.Body = requestBody; 590context.Request.Body = requestBody; 654context.Request.Body = requestBody; 755context.Request.Body = requestBody; 899context.Request.Body = mockStream.Object; 2566context.Request.Body = requestBody; 2626context.Request.Body = requestBody; 2683context.Request.Body = requestBody;
Microsoft.AspNetCore.Http.Extensions.Tests (65)
HttpRequestJsonExtensionsTests.cs (10)
70context.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("1")); 85context.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("[1,2,]")); 106context.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("[1,2]")); 124context.Request.Body = new MemoryStream(Encoding.Unicode.GetBytes(@"{""name"": ""激光這兩個字是甚麼意思""}")); 139context.Request.Body = new TestStream(); 173context.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("1")); 188context.Request.Body = new MemoryStream(Encoding.Unicode.GetBytes(@"{""name"": ""激光這兩個字是甚麼意思""}")); 217context.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("[1,2,]")); 238context.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("[1,2,]")); 260context.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("[1,2,]"));
RequestDelegateFactoryTests.cs (4)
852httpContext.Request.Body = stream; 1936httpContext.Request.Body = new ExceptionThrowingRequestBodyStream(exception); 1969httpContext.Request.Body = new ExceptionThrowingRequestBodyStream(exception); 2877httpContext.Request.Body = stream;
RequestDelegateGenerator\RequestDelegateCreationTestBase.cs (1)
227httpContext.Request.Body = stream;
RequestDelegateGenerator\RequestDelegateCreationTests.Arrays.cs (5)
626httpContext.Request.Body = stream; 653httpContext.Request.Body = stream; 680httpContext.Request.Body = stream; 707httpContext.Request.Body = stream; 734httpContext.Request.Body = stream;
RequestDelegateGenerator\RequestDelegateCreationTests.BindAsync.cs (2)
213httpContext.Request.Body = stream; 269httpContext.Request.Body = stream;
RequestDelegateGenerator\RequestDelegateCreationTests.Filters.cs (1)
234httpContext.Request.Body = stream;
RequestDelegateGenerator\RequestDelegateCreationTests.Forms.cs (24)
35httpContext.Request.Body = stream; 70httpContext.Request.Body = stream; 105httpContext.Request.Body = stream; 143httpContext.Request.Body = stream; 181httpContext.Request.Body = stream; 222httpContext.Request.Body = stream; 259httpContext.Request.Body = stream; 295httpContext.Request.Body = stream; 369httpContext.Request.Body = stream; 402httpContext.Request.Body = stream; 451httpContext.Request.Body = stream; 491httpContext.Request.Body = stream; 550httpContext.Request.Body = stream; 597httpContext.Request.Body = stream; 644httpContext.Request.Body = stream; 673httpContext.Request.Body = stream; 706httpContext.Request.Body = stream; 736httpContext.Request.Body = stream; 766httpContext.Request.Body = stream; 829httpContext.Request.Body = stream; 873httpContext.Request.Body = stream; 932httpContext.Request.Body = new ExceptionThrowingRequestBodyStream(ioException); 964httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(new string('x', 2049))); 1001httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(new string('x', 2049)));
RequestDelegateGenerator\RequestDelegateCreationTests.JsonBody.cs (6)
90httpContext.Request.Body = stream; 233httpContext.Request.Body = stream; 274httpContext.Request.Body = stream; 317httpContext.Request.Body = stream; 358httpContext.Request.Body = stream; 431httpContext.Request.Body = stream;
RequestDelegateGenerator\RequestDelegateCreationTests.Logging.cs (5)
483httpContext.Request.Body = new ExceptionThrowingRequestBodyStream(ioException); 519httpContext.Request.Body = new ExceptionThrowingRequestBodyStream(jsonException); 560httpContext.Request.Body = new ExceptionThrowingRequestBodyStream(jsonException); 599httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("{")); 639httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("{"));
RequestDelegateGenerator\RuntimeCreationTests.ComplexFormBinding.cs (7)
30httpContext.Request.Body = stream; 66httpContext.Request.Body = stream; 98httpContext.Request.Body = stream; 135httpContext.Request.Body = stream; 172httpContext.Request.Body = stream; 207httpContext.Request.Body = stream; 244httpContext.Request.Body = stream;
Microsoft.AspNetCore.Http.Microbenchmarks (1)
src\Http\Http.Extensions\test\RequestDelegateGenerator\RequestDelegateCreationTestBase.cs (1)
227httpContext.Request.Body = stream;
Microsoft.AspNetCore.Http.Tests (18)
Features\FormFeatureTests.cs (14)
39context.Request.Body = new NonSeekableReadStream(formContent); 56context.Request.Body = new NonSeekableReadStream(formContent); 206context.Request.Body = new NonSeekableReadStream(formContent); 241context.Request.Body = new NonSeekableReadStream(formContent); 278context.Request.Body = new NonSeekableReadStream(formContent); 326context.Request.Body = new NonSeekableReadStream(formContent); 363context.Request.Body = new NonSeekableReadStream(formContent); 411context.Request.Body = new NonSeekableReadStream(formContent); 463context.Request.Body = new NonSeekableReadStream(formContent.ToArray()); 487context.Request.Body = new NonSeekableReadStream(formContent.ToArray()); 511context.Request.Body = new NonSeekableReadStream(formContent.ToArray()); 535context.Request.Body = new NonSeekableReadStream(formContent.ToArray()); 560context.Request.Body = new NonSeekableReadStream(formContent); 603context.Request.Body = new NonSeekableReadStream(formContent);
Features\RequestBodyPipeFeatureTests.cs (4)
18context.Request.Body = expectedStream; 31context.Request.Body = new MemoryStream(Encoding.ASCII.GetBytes("hahaha")); 36context.Request.Body = new MemoryStream(Encoding.ASCII.GetBytes(expectedString)); 56context.Request.Body = mockStream.Object;
Microsoft.AspNetCore.HttpLogging (2)
HttpLoggingMiddleware.cs (2)
170request.Body = requestBufferingStream; 279context.Request.Body = originalBody;
Microsoft.AspNetCore.HttpLogging.Tests (15)
HttpLoggingMiddlewareTests.cs (15)
299httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("Hello World")); 330httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(expected)); 358httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(expected)); 386httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(expected)); 422httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(input)); 458httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(input)); 483httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(input)); 509httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(input)); 548httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(expected)); 588httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes(expected)); 627httpContext.Request.Body = new MemoryStream(encoding.GetBytes(expected)); 665httpContext.Request.Body = new MemoryStream(Encoding.ASCII.GetBytes(expected)); 704httpContext.Request.Body = new MemoryStream(Encoding.UTF32.GetBytes(expected)); 1524httpContext.Request.Body = Stream.Null; 1964httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("test"));
Microsoft.AspNetCore.Mvc.Core.Test (10)
Formatters\JsonInputFormatterTestBase.cs (2)
547httpContext.Request.Body = testBufferedReadStream; 641httpContext.Request.Body = requestStream;
ModelBinding\Binders\BodyModelBinderTests.cs (8)
253httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("Bad data!")); 301httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("Bad data!")); 330httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("Bad data!")); 372httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("Bad data!")); 401httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("Bad data!")); 448httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("valid data!")); 483httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("valid data!")); 512httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("valid data"));
Microsoft.AspNetCore.Mvc.Formatters.Xml.Test (12)
XmlDataContractSerializerInputFormatterTest.cs (6)
149httpContext.Request.Body = new NonSeekableReadStream(contentBytes, allowSyncReads: true); 181httpContext.Request.Body = testBufferedReadStream; 213httpContext.Request.Body = new NonSeekableReadStream(contentBytes); 248httpContext.Request.Body = new NonSeekableReadStream(contentBytes, allowSyncReads: false); 280httpContext.Request.Body = new NonSeekableReadStream(contentBytes); 339httpContext.Request.Body = new NonSeekableReadStream(contentBytes);
XmlSerializerInputFormatterTest.cs (6)
54httpContext.Request.Body = new NonSeekableReadStream(contentBytes, allowSyncReads: true); 91httpContext.Request.Body = new NonSeekableReadStream(contentBytes); 127httpContext.Request.Body = new NonSeekableReadStream(contentBytes, allowSyncReads: false); 163httpContext.Request.Body = new NonSeekableReadStream(contentBytes); 205httpContext.Request.Body = new NonSeekableReadStream(contentBytes); 636httpContext.Request.Body = testBufferedReadStream;
Microsoft.AspNetCore.Mvc.FunctionalTests (1)
AntiforgeryMiddlewareTest.cs (1)
111context.Request.Body = new SizeLimitedStream(context.Request.Body, context.Features.Get<IHttpMaxRequestBodySizeFeature>()?.MaxRequestBodySize);
Microsoft.AspNetCore.Mvc.IntegrationTests (37)
BodyValidationIntegrationTests.cs (19)
36request.Body = new MemoryStream(Encoding.UTF8.GetBytes(input)); 77request.Body = new MemoryStream(Encoding.UTF8.GetBytes(input)); 111request.Body = new MemoryStream(Encoding.UTF8.GetBytes(input)); 161request.Body = new MemoryStream(Encoding.UTF8.GetBytes(input)); 202request.Body = new MemoryStream(Encoding.UTF8.GetBytes(input)); 242request.Body = new MemoryStream(Encoding.UTF8.GetBytes(input)); 278request.Body = new MemoryStream(Encoding.UTF8.GetBytes(input)); 323request.Body = new MemoryStream(Encoding.UTF8.GetBytes(input)); 371request.Body = new MemoryStream(Encoding.UTF8.GetBytes(string.Empty)); 413request.Body = new MemoryStream(Encoding.UTF8.GetBytes(string.Empty)); 447request.Body = new MemoryStream(Encoding.UTF8.GetBytes(string.Empty)); 527request.Body = new MemoryStream(Encoding.UTF8.GetBytes("{ \"Number\": 5 }")); 554request.Body = new MemoryStream(Encoding.UTF8.GetBytes("{ \"Number\": \"not a number\" }")); 620request.Body = new MemoryStream(Encoding.UTF8.GetBytes(string.Empty)); 665request.Body = new MemoryStream(Encoding.UTF8.GetBytes(string.Empty)); 717request.Body = new MemoryStream(Encoding.UTF8.GetBytes(inputText)); 776request.Body = new MemoryStream(Encoding.UTF8.GetBytes(inputText)); 821request.Body = new MemoryStream(Encoding.UTF8.GetBytes(inputText)); 867request.Body = new MemoryStream(Encoding.UTF8.GetBytes(inputText));
ComplexRecordIntegrationTest.cs (1)
4206request.Body = stream;
ComplexTypeIntegrationTestBase.cs (1)
3705request.Body = stream;
JQueryFormatModelBindingIntegrationTest.cs (1)
68request.Body = new MemoryStream(Encoding.UTF8.GetBytes(
SimpleTypeModelBinderIntegrationTest.cs (1)
294request.Body = new MemoryStream(Encoding.UTF8.GetBytes(input));
ValidationIntegrationTests.cs (7)
98request.Body = new MemoryStream(Encoding.UTF8.GetBytes("{\"accountId\": 15,\"amount\": 250.0}")); 140request.Body = new MemoryStream(Encoding.UTF8.GetBytes("{\"accountId\": 40,\"amount\": 250.0}")); 1737request.Body = new MemoryStream(Encoding.UTF8.GetBytes(input)); 1791request.Body = new MemoryStream(Encoding.UTF8.GetBytes("{ message: \"Hello\" }")); 1881request.Body = new MemoryStream(Encoding.UTF8.GetBytes("{ message: \"Hello\" }")); 1928request.Body = new MemoryStream(Encoding.UTF8.GetBytes("{ message: \"Hello There\" }")); 1986request.Body = new MemoryStream(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(input)));
ValidationWithRecordIntegrationTests.cs (7)
90request.Body = new MemoryStream(Encoding.UTF8.GetBytes("{\"accountId\": 15,\"amount\": 250.0}")); 132request.Body = new MemoryStream(Encoding.UTF8.GetBytes("{\"accountId\": 40,\"amount\": 250.0}")); 1540request.Body = new MemoryStream(Encoding.UTF8.GetBytes(input)); 1594request.Body = new MemoryStream(Encoding.UTF8.GetBytes("{ message: \"Hello\" }")); 1684request.Body = new MemoryStream(Encoding.UTF8.GetBytes("{ message: \"Hello\" }")); 1731request.Body = new MemoryStream(Encoding.UTF8.GetBytes("{ message: \"Hello There\" }")); 1781request.Body = new MemoryStream(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(input)));
Microsoft.AspNetCore.Mvc.NewtonsoftJson.Test (9)
NewtonsoftJsonInputFormatterTest.cs (5)
41httpContext.Request.Body = new NonSeekableReadStream(contentBytes, allowSyncReads: false); 77httpContext.Request.Body = new NonSeekableReadStream(contentBytes); 113httpContext.Request.Body = new NonSeekableReadStream(contentBytes); 505httpContext.Request.Body = new NonSeekableReadStream(contentBytes, allowSyncReads: false); 548httpContext.Request.Body = new NonSeekableReadStream(contentBytes, allowSyncReads: false);
NewtonsoftJsonPatchInputFormatterTest.cs (2)
40httpContext.Request.Body = new NonSeekableReadStream(contentBytes, allowSyncReads: false); 77httpContext.Request.Body = new NonSeekableReadStream(contentBytes);
src\Mvc\Mvc.Core\test\Formatters\JsonInputFormatterTestBase.cs (2)
547httpContext.Request.Body = testBufferedReadStream; 641httpContext.Request.Body = requestStream;
Microsoft.AspNetCore.Owin.Tests (1)
OwinEnvironmentTests.cs (1)
24context.Request.Body = Stream.Null;
Microsoft.AspNetCore.RequestDecompression (2)
RequestDecompressionMiddleware.cs (2)
65context.Request.Body = new SizeLimitedStream(decompressionStream, sizeLimit); 70context.Request.Body = request;
Microsoft.AspNetCore.Routing.FunctionalTests (1)
MinimalFormTests.cs (1)
451context.Request.Body = new SizeLimitedStream(context.Request.Body, context.Features.Get<IHttpMaxRequestBodySizeFeature>()?.MaxRequestBodySize);
Microsoft.AspNetCore.Routing.Tests (4)
EndpointRoutingMiddlewareFormOptionsTest.cs (4)
32httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("foo=bar")); 64httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("foo=bar")); 104httpContext.Request.Body = new MemoryStream("foo=bar"u8.ToArray()); 136httpContext.Request.Body = new MemoryStream(Encoding.UTF8.GetBytes("foo=bar"));
Microsoft.AspNetCore.TestHost (2)
ClientHandler.cs (1)
152req.Body = new AsyncStreamWrapper(reader.AsStream(), () => contextBuilder.AllowSynchronousIO);
WebSocketClient.cs (1)
88request.Body = Stream.Null;
422 references to Body
BasicWebSite (1)
StartupRequestLimitSize.cs (1)
28httpContext.Request.Body,
Binding.Http.IntegrationTests (1)
MtomBindingTestHelper.cs (1)
56while (await context.Request.Body.ReadAsync(buffer, 0, 8192) != 0) { }
FormatterWebSite (1)
StringInputFormatter.cs (1)
23using (var reader = new StreamReader(request.Body, effectiveEncoding))
Http3SampleApp (1)
Startup.cs (1)
23var length = await context.Request.Body.ReadAsync(memory);
HttpStress (4)
Program.cs (4)
474await context.Request.Body.CopyToAsync(s); 481await context.Request.Body.CopyToAsync(context.Response.Body); 487while ((await context.Request.Body.ReadAsync(buffer)) != 0) 501await context.Request.Body.CopyToAsync(Stream.Null);
IIS.Tests (17)
ClientDisconnectTests.cs (4)
115await ctx.Request.Body.ReadAsync(data); 196var task = ctx.Request.Body.ReadAsync(data, cancellationTokenSource.Token); 243await ctx.Request.Body.ReadAsync(data); 293var task = ctx.Request.Body.ReadAsync(data);
HttpBodyControlFeatureTests.cs (1)
39ctx.Request.Body.Read(new byte[10]);
MaxRequestBodySizeTests.cs (11)
36await ctx.Request.Body.ReadAsync(new byte[2000]); 78await ctx.Request.Body.ReadAsync(new byte[2000]); 114await ctx.Request.Body.ReadAsync(new byte[2000]); 141await ctx.Request.Body.ReadAsync(new byte[2000]); 167await ctx.Request.Body.ReadAsync(new byte[2000]); 190await ctx.Request.Body.ReadAsync(new byte[2000]); 214await ctx.Request.Body.ReadAsync(new byte[2000]); 246Assert.Equal(1, await ctx.Request.Body.ReadAsync(buffer, 0, 1)); 284var num = await ctx.Request.Body.ReadAsync(new byte[2000]); 325async () => await ctx.Request.Body.ReadAsync(buffer, 0, 1)); 327async () => await ctx.Request.Body.ReadAsync(buffer, 0, 1));
ResponseAbortTests.cs (1)
78await ctx.Request.Body.ReadAsync(a);
InMemory.FunctionalTests (137)
BadHttpRequestTests.cs (4)
214await context.Request.Body.ReadAsync(new byte[1], 0, 1); 390await using (var server = new TestServer(context => context.Request.Body.DrainAsync(default), new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)) { DiagnosticSource = diagListener })) 456await using (var server = new TestServer(context => context.Request.Body.DrainAsync(default), new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)) { DiagnosticSource = diagListener })) 531await using (var server = new TestServer(context => context.Request.Body.DrainAsync(default), new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory)) { DiagnosticSource = diagListener }))
ChunkedRequestTests.cs (9)
29var count = await request.Body.ReadAsync(buffer, 0, buffer.Length); 63await request.Body.CopyToAsync(data); 261while (await request.Body.ReadAsync(buffer, 0, buffer.Length) != 0) 498while (await context.Request.Body.ReadAsync(buffer, 0, buffer.Length) != 0) 542while (await context.Request.Body.ReadAsync(buffer, 0, buffer.Length) != 0) 587while (await request.Body.ReadAsync(buffer, 0, buffer.Length) != 0) 669while (await request.Body.ReadAsync(buffer, 0, buffer.Length) != 0) 713while (await request.Body.ReadAsync(buffer, 0, buffer.Length) != 0) 863var readTask = httpContext.Request.Body.CopyToAsync(Stream.Null);
Http2\Http2ConnectionTests.cs (1)
1168var read = await context.Request.Body.ReadAsync(new byte[10], 0, 10);
Http2\Http2KeepAliveTests.cs (2)
279await c.Request.Body.FlushAsync(); 333await c.Request.Body.FlushAsync();
Http2\Http2StreamTests.cs (26)
878var read = await context.Request.Body.ReadAsync(buffer, 0, buffer.Length); 880read = await context.Request.Body.ReadAsync(buffer, 0, buffer.Length); 908var read = await context.Request.Body.ReadAsync(buffer, 0, buffer.Length); 910read = await context.Request.Body.ReadAsync(buffer, 0, buffer.Length); 956var read = await context.Request.Body.ReadAsync(buffer, 0, buffer.Length); 960read = await context.Request.Body.ReadAsync(buffer, total, buffer.Length - total); 1050var read = await context.Request.Body.ReadAsync(buffer, 0, buffer.Length); 1054read = await context.Request.Body.ReadAsync(buffer, total, buffer.Length - total); 1151while (await context.Request.Body.ReadAsync(buffer, 0, buffer.Length) > 0) { } 1186while (await context.Request.Body.ReadAsync(buffer, 0, buffer.Length) > 0) { } 1221while (await context.Request.Body.ReadAsync(buffer, 0, buffer.Length) > 0) { } 1257while (await context.Request.Body.ReadAsync(buffer, 0, buffer.Length) > 0) { } 1867var read = await context.Request.Body.ReadAsync(buffer, 0, buffer.Length); 1869read = await context.Request.Body.ReadAsync(buffer, 0, buffer.Length); 1912while (await context.Request.Body.ReadAsync(buffer, 0, buffer.Length) > 0) { } 1953var read = await context.Request.Body.ReadAsync(buffer, 0, buffer.Length); 1955read = await context.Request.Body.ReadAsync(buffer, 0, buffer.Length); 1997while (await context.Request.Body.ReadAsync(buffer, 0, buffer.Length) > 0) { } 2058while (await context.Request.Body.ReadAsync(buffer, 0, buffer.Length) > 0) { } 2114var read = await context.Request.Body.ReadAsync(buffer, 0, buffer.Length); 2117read = await context.Request.Body.ReadAsync(buffer, 0, buffer.Length); 3251var readTask = context.Request.Body.ReadAsync(new byte[100], 0, 100).DefaultTimeout(); 3293var read = await context.Request.Body.ReadAsync(new byte[100], 0, 100).DefaultTimeout(); 3294var readTask = context.Request.Body.ReadAsync(new byte[100], 0, 100).DefaultTimeout(); 3429var thrownExTask = Assert.ThrowsAnyAsync<OperationCanceledException>(() => context.Request.Body.ReadAsync(buffer, 0, buffer.Length)); 3454var thrownExTask = Assert.ThrowsAnyAsync<OperationCanceledException>(() => context.Request.Body.ReadAsync(buffer, 0, buffer.Length));
Http2\Http2TestBase.cs (6)
212await context.Request.Body.CopyToAsync(ms); 241while ((received = await context.Request.Body.ReadAsync(buffer, 0, buffer.Length)) > 0) 254while ((received = await context.Request.Body.ReadAsync(buffer, 0, buffer.Length)) > 0) 265while ((received = await context.Request.Body.ReadAsync(buffer, 0, buffer.Length)) > 0) 341received += await context.Request.Body.ReadAsync(buffer, 0, buffer.Length); 344var stalledReadTask = context.Request.Body.ReadAsync(buffer, 0, buffer.Length);
Http2\Http2TimeoutTests.cs (1)
337while ((received = await context.Request.Body.ReadAsync(buffer, 0, buffer.Length)) > 0)
Http2\Http2WebSocketTests.cs (5)
35Assert.Equal(0, await context.Request.Body.ReadAsync(new byte[1])); 97Assert.Equal(0, await context.Request.Body.ReadAsync(new byte[1])); 173Assert.Equal(0, await context.Request.Body.ReadAsync(new byte[1])); 455Assert.Equal(0, await context.Request.Body.ReadAsync(new byte[1])); 464Assert.Equal(0, await context.Request.Body.ReadAsync(new byte[1]));
Http3\Http3ConnectionTests.cs (3)
44while ((received = await context.Request.Body.ReadAsync(buffer, 0, buffer.Length)) > 0) 84while ((received = await context.Request.Body.ReadAsync(buffer, 0, buffer.Length)) > 0) 147while ((received = await context.Request.Body.ReadAsync(buffer, 0, buffer.Length)) > 0)
Http3\Http3StreamTests.cs (16)
559var read = await context.Request.Body.ReadAsync(buffer, 0, buffer.Length); 561read = await context.Request.Body.ReadAsync(buffer, 0, buffer.Length); 588var read = await context.Request.Body.ReadAsync(buffer, 0, buffer.Length); 592read = await context.Request.Body.ReadAsync(buffer, total, buffer.Length - total); 1983await c.Request.Body.DrainAsync(default); 2057await c.Request.Body.ReadAsync(data); 2508var read = await context.Request.Body.ReadAsync(buffer, 0, buffer.Length); 2510read = await context.Request.Body.ReadAsync(buffer, 0, buffer.Length); 2546while (await context.Request.Body.ReadAsync(buffer, 0, buffer.Length) > 0) { } 2581var read = await context.Request.Body.ReadAsync(buffer, 0, buffer.Length); 2583read = await context.Request.Body.ReadAsync(buffer, 0, buffer.Length); 2618while (await context.Request.Body.ReadAsync(buffer, 0, buffer.Length) > 0) { } 2671while (await context.Request.Body.ReadAsync(buffer, 0, buffer.Length) > 0) { } 2719var read = await context.Request.Body.ReadAsync(buffer, 0, buffer.Length); 2722read = await context.Request.Body.ReadAsync(buffer, 0, buffer.Length); 2834readCount += await context.Request.Body.ReadAsync(buffer.AsMemory(readCount, 100 - readCount));
Http3\Http3TestBase.cs (3)
68while ((received = await context.Request.Body.ReadAsync(buffer, 0, buffer.Length)) > 0) 83received += await context.Request.Body.ReadAsync(buffer, 0, buffer.Length); 86var stalledReadTask = context.Request.Body.ReadAsync(buffer, 0, buffer.Length);
Http3\Http3TimeoutTests.cs (1)
434while ((received = await context.Request.Body.ReadAsync(buffer, 0, buffer.Length)) > 0)
HttpsConnectionMiddlewareTests.cs (2)
1035var body = await new StreamReader(context.Request.Body).ReadToEndAsync(); 1491var count = await request.Body.ReadAsync(buffer, 0, buffer.Length);
KeepAliveTimeoutTests.cs (1)
282while (await httpContext.Request.Body.ReadAsync(buffer, 0, buffer.Length) > 0)
KestrelMetricsTests.cs (2)
405await c.Request.Body.ReadUntilEndAsync(); 925await request.Body.FillBufferUntilEndAsync(buffer).DefaultTimeout();
MaxRequestBodySizeTests.cs (16)
38async () => await context.Request.Body.ReadAsync(buffer, 0, 1)); 79using (var stream = new StreamReader(context.Request.Body)) 126using (var stream = new StreamReader(context.Request.Body)) 181async () => await context.Request.Body.ReadAsync(buffer, 0, 1)); 221Assert.Equal(1, await context.Request.Body.ReadAsync(buffer, 0, 1)); 223Assert.Equal(0, await context.Request.Body.ReadAsync(buffer, 0, 1)); 251await using (var server = new TestServer(context => context.Request.Body.CopyToAsync(Stream.Null), 291Assert.Equal(1, await context.Request.Body.ReadAsync(buffer, 0, 1)); 378async () => await context.Request.Body.ReadAsync(buffer, 0, 1)); 380async () => await context.Request.Body.ReadAsync(buffer, 0, 1)); 431count = await context.Request.Body.ReadAsync(buffer, 0, 11); 476count = await context.Request.Body.ReadAsync(buffer, offset, 11 - offset); 528count = await context.Request.Body.ReadAsync(buffer, 0, 11); 539count = await context.Request.Body.ReadAsync(buffer, 0, 11); 591async () => await context.Request.Body.ReadAsync(buffer, 0, 1)); 593async () => await context.Request.Body.ReadAsync(buffer, 0, 1));
RequestBodyTimeoutTests.cs (2)
58var readTask = context.Request.Body.ReadAsync(new byte[1], 0, 1); 168var readTask = context.Request.Body.ReadAsync(new byte[1], 0, 1);
RequestHeadersTimeoutTests.cs (1)
160await httpContext.Request.Body.ReadAsync(new byte[1], 0, 1);
RequestTests.cs (19)
32if (context.Request.Body is MemoryStream) 121await context.Request.Body.FillEntireBufferAsync(data, cts.Token).DefaultTimeout(); 135var task = context.Request.Body.ReadAsync(data, 0, data.Length, cts.Token); 925Assert.Equal(0, await httpContext.Request.Body.ReadAsync(new byte[1], 0, 1).DefaultTimeout()); 1398if (context.Request.Body != lastStream) 1400lastStream = context.Request.Body; 1415await context.Request.Body.CopyToAsync(ms); 1698var ioEx = Assert.Throws<InvalidOperationException>(() => context.Request.Body.Read(new byte[1], 0, 1)); 1701var ioEx2 = Assert.Throws<InvalidOperationException>(() => context.Request.Body.CopyTo(Stream.Null)); 1706offset += await context.Request.Body.ReadAsync(buffer, offset, 5 - offset); 1709Assert.Equal(0, await context.Request.Body.ReadAsync(new byte[1], 0, 1)); 1749offset += context.Request.Body.Read(buffer, offset, 5 - offset); 1752Assert.Equal(0, await context.Request.Body.ReadAsync(new byte[1], 0, 1)); 1791var ioEx = Assert.Throws<InvalidOperationException>(() => context.Request.Body.Read(new byte[1], 0, 1)); 1794var ioEx2 = Assert.Throws<InvalidOperationException>(() => context.Request.Body.CopyTo(Stream.Null)); 1798var length = await context.Request.Body.FillBufferUntilEndAsync(buffer).DefaultTimeout(); 1839offset += context.Request.Body.Read(buffer, offset, 5 - offset); 1842Assert.Equal(0, await context.Request.Body.ReadAsync(new byte[1], 0, 1)); 1873await httpContext.Request.Body.ReadAsync(new byte[1], 0, 1);
ResponseTests.cs (9)
344await context.Request.Body.ReadAsync(new byte[1], 0, 1); 361await context.Request.Body.ReadAsync(new byte[1], 0, 1); 487async () => await httpContext.Request.Body.ReadAsync(new byte[1], 0, 1)); 1541await httpContext.Request.Body.ReadAsync(new byte[1], 0, 1); 2039return httpContext.Request.Body.ReadAsync(new byte[1], 0, 1); 2109return httpContext.Request.Body.ReadAsync(new byte[1], 0, 1); 2155await httpContext.Request.Body.ReadAsync(new byte[1], 0, 1); 2260Assert.Equal(0, await httpContext.Request.Body.ReadAsync(new byte[1], 0, 1).DefaultTimeout()); 2330using (var reader = new StreamReader(request.Body, Encoding.ASCII))
src\Servers\Kestrel\shared\test\TestApp.cs (4)
22await request.Body.FillBufferUntilEndAsync(buffer).DefaultTimeout(); 32await request.Body.CopyToAsync(data); 52await request.Body.FillBufferUntilEndAsync(buffer).DefaultTimeout(); 66await request.Body.CopyToAsync(data);
UpgradeTests.cs (4)
77var read = await context.Request.Body.ReadAsync(buffer, 0, 128).DefaultTimeout(); 169Assert.Equal(1, await context.Request.Body.ReadAsync(new byte[10], 0, 10)); 204Assert.Equal(0, await context.Request.Body.ReadAsync(new byte[10], 0, 10)); 241var length = await context.Request.Body.FillBufferUntilEndAsync(new byte[100]);
InProcessWebSite (31)
src\Servers\IIS\IIS\test\testassets\InProcessWebSite\Startup.cs (30)
305Assert.NotNull(ctx.Request.Body); 308Assert.Same(body, ctx.Request.Body); 563var result = await ctx.Request.Body.ReadAsync(readBuffer, 0, 1); 566result = await ctx.Request.Body.ReadAsync(readBuffer, 0, 1); 576var result = await ctx.Request.Body.ReadAsync(readBuffer, 0, 4096); 579result = await ctx.Request.Body.ReadAsync(readBuffer, 0, 4096); 590await ctx.Request.Body.ReadAsync(readBuffer, 0, 1); 632var result = await ctx.Request.Body.ReadAsync(readBuffer, 0, readBuffer.Length); 636result = await ctx.Request.Body.ReadAsync(readBuffer, 0, readBuffer.Length); 645var result = await ctx.Request.Body.ReadAsync(readBuffer, 0, readBuffer.Length); 650result = await ctx.Request.Body.ReadAsync(readBuffer, 0, readBuffer.Length); 667var reader = new StreamReader(ctx.Request.Body); 699var reader = new StreamReader(ctx.Request.Body); 720count += await ctx.Request.Body.ReadAsync(data, count, data.Length - count); 727using (var reader = new StreamReader(ctx.Request.Body)) 738var result = await ctx.Request.Body.ReadAsync(readBuffer, 0, readBuffer.Length); 745result = await ctx.Request.Body.ReadAsync(readBuffer, 0, readBuffer.Length); 769await ctx.Request.Body.CopyToAsync(ctx.Response.Body); 775await ctx.Request.Body.ReadAsync(buffer, 0, 6); 776await ctx.Request.Body.ReadAsync(buffer, 6, 5); 788await ctx.Request.Body.ReadAsync(null, 0, 0); 799await ctx.Request.Body.ReadAsync(new byte[1], -1, 0); 810await ctx.Request.Body.ReadAsync(new byte[1], 2, 0); 821await ctx.Request.Body.ReadAsync(new byte[1], 0, -1); 832await ctx.Request.Body.ReadAsync(new byte[1], 0, -1); 843await ctx.Request.Body.ReadAsync(new byte[3], 1, 3); 860count = await ctx.Request.Body.ReadAsync(null, 0, 0); 864count = await ctx.Request.Body.ReadAsync(null, 0, 0); 868count = await ctx.Request.Body.ReadAsync(new byte[1], 0, 0); 872count = await ctx.Request.Body.ReadAsync(new byte[1], 0, 0);
src\Servers\IIS\IIS\test\testassets\InProcessWebSite\Startup.WebSockets.cs (1)
50Assert.Equal(0, await context.Request.Body.ReadAsync(singleByteArray, 0, 1));
Interop.FunctionalTests (19)
H2SpecTests.cs (1)
152await context.Request.Body.CopyToAsync(Stream.Null);
Http3\Http3RequestTests.cs (10)
331var data = await context.Request.Body.ReadUntilEndAsync(); 403var body = context.Request.Body; 466var body = context.Request.Body; 549readAsyncTask.SetResult(context.Request.Body.ReadAsync(new byte[1024]).AsTask()); 710var body = context.Request.Body; 982var requestBody = context.Request.Body; 1075var requestBody = context.Request.Body; 1173var requestBody = context.Request.Body; 2009var readTask = context.Request.Body.ReadUntilEndAsync(); 2125var data = await context.Request.Body.ReadUntilEndAsync();
HttpClientHttp2InteropTests.cs (8)
416using var streamReader = new StreamReader(context.Request.Body); 715using var streamReader = new StreamReader(context.Request.Body); 763var count = await context.Request.Body.ReadAsync(new byte[11], 0, 11); 774using var streamReader = new StreamReader(context.Request.Body); 823var readTask = context.Request.Body.ReadAsync(new byte[11], 0, 11); 869await ReadStreamHelloWorld(context.Request.Body); 870var readTask = context.Request.Body.ReadAsync(new byte[11], 0, 11); 1505read = await context.Request.Body.ReadAsync(buffer, 0, buffer.Length).DefaultTimeout();
JwtBearerSample (1)
Startup.cs (1)
75var reader = new StreamReader(context.Request.Body);
Kestrel.SampleApp (2)
ClientCertBufferingFeature.cs (2)
61if (!_context.Request.Body.CanSeek) 66var body = _context.Request.Body;
Microsoft.AspNetCore.Authentication.OpenIdConnect (2)
OpenIdConnectHandler.cs (2)
121&& Request.Body.CanRead) 664&& Request.Body.CanRead)
Microsoft.AspNetCore.Authentication.WsFederation (1)
WsFederationHandler.cs (1)
158&& Request.Body.CanRead)
Microsoft.AspNetCore.Diagnostics.Middleware.Tests (2)
Logging\AcceptanceTests.cs (2)
61await context.Request.Body.DrainAsync(default); 87await context.Request.Body.DrainAsync(default).ConfigureAwait(false);
Microsoft.AspNetCore.Grpc.JsonTranscoding (2)
Internal\JsonRequestHelpers.cs (2)
209var (stream, usesTranscodingStream) = GetStream(serverCallContext.HttpContext.Request.Body, serverCallContext.RequestEncoding); 348using var fs = new FileBufferingReadStream(serverCallContext.HttpContext.Request.Body, memoryThreshold);
Microsoft.AspNetCore.Http (12)
Extensions\HttpRequestRewindExtensions.cs (4)
12/// Ensure the <paramref name="request"/> <see cref="HttpRequest.Body"/> can be read multiple times. Normally 27/// Ensure the <paramref name="request"/> <see cref="HttpRequest.Body"/> can be read multiple times. Normally 47/// Ensure the <paramref name="request"/> <see cref="HttpRequest.Body"/> can be read multiple times. Normally 66/// Ensure the <paramref name="request"/> <see cref="HttpRequest.Body"/> can be read multiple times. Normally
Features\FormFeature.cs (4)
229var multipartReader = new MultipartReader(boundary, _request.Body) 268file = new FormFile(_request.Body, section.BaseStreamOffset.GetValueOrDefault(), section.Body.Length, name, fileName); 313if (_request.Body.CanSeek) 315_request.Body.Seek(0, SeekOrigin.Begin);
Features\RequestBodyPipeFeature.cs (3)
36!ReferenceEquals(_streamInstanceWhenWrapped, _context.Request.Body)) 38_streamInstanceWhenWrapped = _context.Request.Body; 39_internalPipeReader = PipeReader.Create(_context.Request.Body, _defaultReaderOptions);
Internal\BufferingHelper.cs (1)
17var body = request.Body;
Microsoft.AspNetCore.Http.Connections (1)
Internal\HttpConnectionDispatcher.cs (1)
488await context.Request.Body.CopyToAsync(connection.ApplicationStream, bufferSize);
Microsoft.AspNetCore.Http.Extensions (3)
HttpRequestJsonExtensions.cs (2)
319return (httpContext.Request.Body, false); 322var inputStream = Encoding.CreateTranscodingStream(httpContext.Request.Body, encoding, Encoding.UTF8, leaveOpen: true);
RequestDelegateFactory.cs (1)
100private static readonly MemberExpression RequestStreamExpr = Expression.Property(HttpRequestExpr, typeof(HttpRequest).GetProperty(nameof(HttpRequest.Body))!);
Microsoft.AspNetCore.Http.Extensions.Tests (17)
RequestDelegateFactoryTests.cs (2)
3545var body = await JsonSerializer.DeserializeAsync<JsonTodo>(context.Request.Body); 3546context.Request.Body.Position = 0;
RequestDelegateGenerator\RequestDelegateCreationTests.JsonBody.cs (12)
239Assert.Same(httpContext.Request.Body, stream); 242httpContext.Request.Body.Position = 0; 244int read = await httpContext.Request.Body.ReadAsync(data.AsMemory()); 248httpContext.Request.Body.Position = 0; 280Assert.Same(httpContext.Request.Body, stream); 283httpContext.Request.Body.Position = 0; 285int read = await httpContext.Request.Body.ReadAsync(data.AsMemory()); 289httpContext.Request.Body.Position = 0; 324Assert.Same(httpContext.Request.Body, stream); 328int read = await httpContext.Request.Body.ReadAsync(new byte[requestBodyBytes.Length].AsMemory()); 365Assert.Same(httpContext.Request.Body, stream); 369int read = await httpContext.Request.Body.ReadAsync(new byte[requestBodyBytes.Length].AsMemory());
RequestDelegateGenerator\SharedTypes.cs (3)
92var body = await JsonSerializer.DeserializeAsync<JsonTodo>(context.Request.Body); 93context.Request.Body.Position = 0; 208context.Request.Body.Position = 0;
Microsoft.AspNetCore.Http.Microbenchmarks (3)
src\Http\Http.Extensions\test\RequestDelegateGenerator\SharedTypes.cs (3)
92var body = await JsonSerializer.DeserializeAsync<JsonTodo>(context.Request.Body); 93context.Request.Body.Position = 0; 208context.Request.Body.Position = 0;
Microsoft.AspNetCore.Http.Tests (2)
Features\FormFeatureTests.cs (2)
65Assert.Equal(bufferRequest, context.Request.Body.CanSeek); 68Assert.Equal(0, context.Request.Body.Position);
Microsoft.AspNetCore.HttpLogging (3)
HttpLoggingFields.cs (1)
125/// Flag for logging the HTTP Request <see cref="HttpRequest.Body"/>.
HttpLoggingMiddleware.cs (2)
163originalBody = request.Body; 165request.Body,
Microsoft.AspNetCore.HttpLogging.Tests (30)
HttpLoggingMiddlewareTests.cs (30)
124var res = await c.Request.Body.ReadAsync(arr); 155var res = await c.Request.Body.ReadAsync(arr); 187var res = await c.Request.Body.ReadAsync(arr); 219var res = await c.Request.Body.ReadAsync(arr); 250var res = await c.Request.Body.ReadAsync(arr); 319var res = await c.Request.Body.ReadAsync(arr); 348c.Request.Body.CopyTo(ms); 376await c.Request.Body.CopyToAsync(ms); 408var res = await c.Request.Body.ReadAsync(arr); 444var res = await c.Request.Body.ReadAsync(arr); 477var res = await c.Request.Body.ReadAsync(arr); 502_ = await c.Request.Body.ReadAsync(new byte[0]); 503var res = await c.Request.Body.ReadAsync(arr); 537var res = await c.Request.Body.ReadAsync(arr); 574var res = await c.Request.Body.ReadAsync(arr); 613var res = await c.Request.Body.ReadAsync(arr); 651var res = await c.Request.Body.ReadAsync(arr); 690var res = await c.Request.Body.ReadAsync(arr); 1510await c.Request.Body.DrainAsync(default); 1579await c.Request.Body.DrainAsync(default); 1927await c.Request.Body.ReadAsync(new byte[100]); 1993var res = await context.Request.Body.ReadAsync(arr); 2033await c.Request.Body.ReadAsync(new byte[100]); 2039await c.Request.Body.ReadAsync(new byte[100]); 2045await c.Request.Body.ReadAsync(new byte[100]); 2052await c.Request.Body.ReadAsync(new byte[100]); 2058await c.Request.Body.ReadAsync(new byte[100]); 2064await c.Request.Body.ReadAsync(new byte[100]); 2070await c.Request.Body.ReadAsync(new byte[100]); 2076await c.Request.Body.ReadAsync(new byte[100]);
Microsoft.AspNetCore.Mvc.Core (4)
Formatters\SystemTextJsonInputFormatter.cs (2)
130return (httpContext.Request.Body, false); 133var inputStream = Encoding.CreateTranscodingStream(httpContext.Request.Body, encoding, Encoding.UTF8, leaveOpen: true);
Infrastructure\IHttpRequestStreamReaderFactory.cs (2)
11/// Creates <see cref="TextReader"/> instances for reading from <see cref="Http.HttpRequest.Body"/>. 18/// <param name="stream">The <see cref="Stream"/>, usually <see cref="Http.HttpRequest.Body"/>.</param>
Microsoft.AspNetCore.Mvc.Core.Test (4)
Formatters\JsonInputFormatterTestBase.cs (4)
124Assert.True(httpContext.Request.Body.CanRead, "Verify that the request stream hasn't been disposed"); 546var testBufferedReadStream = new VerifyDisposeFileBufferingReadStream(httpContext.Request.Body, 1024); 579var requestBody = httpContext.Request.Body; 594var requestBody = httpContext.Request.Body;
Microsoft.AspNetCore.Mvc.Formatters.Xml (6)
XmlDataContractSerializerInputFormatter.cs (3)
105Stream readStream = new NonDisposableStream(request.Body); 114var position = request.Body.Position; 130readStream = new FileBufferingReadStream(request.Body, memoryThreshold);
XmlSerializerInputFormatter.cs (3)
89Stream readStream = new NonDisposableStream(request.Body); 98var position = request.Body.Position; 114readStream = new FileBufferingReadStream(request.Body, memoryThreshold);
Microsoft.AspNetCore.Mvc.Formatters.Xml.Test (4)
XmlDataContractSerializerInputFormatterTest.cs (2)
472Assert.True(context.HttpContext.Request.Body.CanRead); 741request.SetupGet(f => f.Body).Returns(new MemoryStream(contentBytes));
XmlSerializerInputFormatterTest.cs (2)
489Assert.True(context.HttpContext.Request.Body.CanRead); 677request.SetupGet(f => f.Body).Returns(new MemoryStream(contentBytes));
Microsoft.AspNetCore.Mvc.FunctionalTests (1)
AntiforgeryMiddlewareTest.cs (1)
111context.Request.Body = new SizeLimitedStream(context.Request.Body, context.Features.Get<IHttpMaxRequestBodySizeFeature>()?.MaxRequestBodySize);
Microsoft.AspNetCore.Mvc.NewtonsoftJson (3)
NewtonsoftJsonInputFormatter.cs (3)
106var readStream = request.Body; 114var position = request.Body.Position; 130readStream = new FileBufferingReadStream(request.Body, memoryThreshold);
Microsoft.AspNetCore.Mvc.NewtonsoftJson.Test (8)
NewtonsoftJsonInputFormatterTest.cs (2)
130Assert.False(httpContext.Request.Body.CanSeek); 453httpContext.Setup(h => h.Request.Body).Returns(new NonSeekableReadStream(content, allowSyncReads: false));
NewtonsoftJsonPatchInputFormatterTest.cs (2)
95Assert.False(httpContext.Request.Body.CanSeek); 261request.SetupGet(f => f.Body).Returns(new MemoryStream(contentBytes));
src\Mvc\Mvc.Core\test\Formatters\JsonInputFormatterTestBase.cs (4)
124Assert.True(httpContext.Request.Body.CanRead, "Verify that the request stream hasn't been disposed"); 546var testBufferedReadStream = new VerifyDisposeFileBufferingReadStream(httpContext.Request.Body, 1024); 579var requestBody = httpContext.Request.Body; 594var requestBody = httpContext.Request.Body;
Microsoft.AspNetCore.Owin.Tests (1)
OwinEnvironmentTests.cs (1)
85Assert.Same(Stream.Null, context.Request.Body);
Microsoft.AspNetCore.RequestDecompression (2)
DefaultRequestDecompressionProvider.cs (1)
54return matchingProvider.GetDecompressionStream(context.Request.Body);
RequestDecompressionMiddleware.cs (1)
58var request = context.Request.Body;
Microsoft.AspNetCore.RequestDecompression.Tests (6)
RequestDecompressionMiddlewareTests.cs (6)
228await context.Request.Body.CopyToAsync(ms, context.RequestAborted); 299await context.Request.Body.CopyToAsync(ms, context.RequestAborted); 375await context.Request.Body.CopyToAsync(ms, context.RequestAborted); 474await context.Request.Body.CopyToAsync(ms, context.RequestAborted); 558await context.Request.Body.CopyToAsync(ms, context.RequestAborted); 712await context.Request.Body.CopyToAsync(ms, context.RequestAborted);
Microsoft.AspNetCore.Routing.FunctionalTests (4)
MinimalFormTests.cs (1)
451context.Request.Body = new SizeLimitedStream(context.Request.Body, context.Features.Get<IHttpMaxRequestBodySizeFeature>()?.MaxRequestBodySize);
WebHostBuilderExtensionsTest.cs (3)
33var streamReader = new StreamReader(req.Body); 45var streamReader = new StreamReader(req.Body); 63var streamReader = new StreamReader(req.Body);
Microsoft.AspNetCore.Server.HttpSys.FunctionalTests (58)
DelegateTests.cs (1)
152await httpContext.Request.Body.CopyToAsync(memoryStream);
Http2Tests.cs (7)
172return httpContext.Request.Body.CopyToAsync(httpContext.Response.Body); 237return httpContext.Request.Body.CopyToAsync(httpContext.Response.Body); 855var readTask = httpContext.Request.Body.ReadAsync(new byte[10], 0, 10); 902var read = await httpContext.Request.Body.ReadAsync(new byte[10], 0, 10); 905var readTask = httpContext.Request.Body.ReadAsync(new byte[10], 0, 10); 951var read = await httpContext.Request.Body.ReadAsync(new byte[10], 0, 10); 954var readTask = httpContext.Request.Body.ReadAsync(new byte[10], 0, 10);
HttpsTests.cs (1)
57var input = await new StreamReader(httpContext.Request.Body).ReadToEndAsync();
RequestBodyLimitTests.cs (25)
31int read = httpContext.Request.Body.Read(input, 0, input.Length); 54int read = await httpContext.Request.Body.ReadAsync(input, 0, input.Length); 75int read = httpContext.Request.Body.EndRead(httpContext.Request.Body.BeginRead(input, 0, input.Length, null, null)); 98int read = httpContext.Request.Body.Read(input, 0, input.Length); 121int read = await httpContext.Request.Body.ReadAsync(input, 0, input.Length); 142int read = httpContext.Request.Body.EndRead(httpContext.Request.Body.BeginRead(input, 0, input.Length, null, null)); 165var ex = Assert.Throws<BadHttpRequestException>(() => httpContext.Request.Body.Read(input, 0, input.Length)); 168ex = Assert.Throws<BadHttpRequestException>(() => httpContext.Request.Body.Read(input, 0, input.Length)); 190var ex = Assert.Throws<BadHttpRequestException>(() => { var t = httpContext.Request.Body.ReadAsync(input, 0, input.Length); }); 193ex = Assert.Throws<BadHttpRequestException>(() => { var t = httpContext.Request.Body.ReadAsync(input, 0, input.Length); }); 215var ex = Assert.Throws<BadHttpRequestException>(() => httpContext.Request.Body.BeginRead(input, 0, input.Length, null, null)); 218ex = Assert.Throws<BadHttpRequestException>(() => httpContext.Request.Body.BeginRead(input, 0, input.Length, null, null)); 241var ex = Assert.Throws<BadHttpRequestException>(() => httpContext.Request.Body.Read(input, 0, input.Length)); 244ex = Assert.Throws<BadHttpRequestException>(() => httpContext.Request.Body.Read(input, 0, input.Length)); 266var ex = await Assert.ThrowsAsync<BadHttpRequestException>(() => httpContext.Request.Body.ReadAsync(input, 0, input.Length)); 269ex = await Assert.ThrowsAsync<BadHttpRequestException>(() => httpContext.Request.Body.ReadAsync(input, 0, input.Length)); 290var body = httpContext.Request.Body; 318int read = httpContext.Request.Body.Read(input, 0, input.Length); 321var ex = Assert.Throws<BadHttpRequestException>(() => httpContext.Request.Body.Read(input, 0, input.Length)); 344int read = await httpContext.Request.Body.ReadAsync(input, 0, input.Length); 347var ex = await Assert.ThrowsAsync<BadHttpRequestException>(() => httpContext.Request.Body.ReadAsync(input, 0, input.Length)); 370int read = await httpContext.Request.Body.ReadAsync(input, 0, input.Length); 394int read = await httpContext.Request.Body.ReadAsync(input, 0, input.Length);
RequestBodyTests.cs (21)
32int read = httpContext.Request.Body.Read(input, 0, input.Length); 52int read = httpContext.Request.Body.Read(input, 0, 0); 54read = httpContext.Request.Body.Read(input, 0, input.Length); 73int read = await httpContext.Request.Body.ReadAsync(input, 0, input.Length); 91int read = await httpContext.Request.Body.ReadAsync(input, 0, 0); 93read = await httpContext.Request.Body.ReadAsync(input, 0, input.Length); 110int read = httpContext.Request.Body.EndRead(httpContext.Request.Body.BeginRead(input, 0, input.Length, null, null)); 129Assert.Throws<ArgumentNullException>("buffer", () => httpContext.Request.Body.Read(null, 0, 1)); 130Assert.Throws<ArgumentOutOfRangeException>("offset", () => httpContext.Request.Body.Read(input, -1, 1)); 131Assert.Throws<ArgumentOutOfRangeException>("count", () => httpContext.Request.Body.Read(input, input.Length + 1, 1)); 132Assert.Throws<ArgumentOutOfRangeException>("count", () => httpContext.Request.Body.Read(input, 10, -1)); 133Assert.Throws<ArgumentOutOfRangeException>("count", () => httpContext.Request.Body.Read(input, 1, input.Length)); 134Assert.Throws<ArgumentOutOfRangeException>("count", () => httpContext.Request.Body.Read(input, 0, input.Length + 1)); 152int read = httpContext.Request.Body.Read(input, 0, input.Length); 155read = httpContext.Request.Body.Read(input, 0, input.Length); 173int read = await httpContext.Request.Body.ReadAsync(input, 0, input.Length); 176read = await httpContext.Request.Body.ReadAsync(input, 0, input.Length); 192int read = await httpContext.Request.Body.ReadAsync(input, 0, input.Length); 194read = await httpContext.Request.Body.ReadAsync(input, 0, input.Length); 229int read = await httpContext.Request.Body.ReadAsync(input, 0, input.Length);
RequestTests.cs (1)
564await httpContext.Request.Body.ReadAsync(new byte[10]).DefaultTimeout();
ResponseTests.cs (1)
224var readTask = httpContext.Request.Body.ReadAsync(new byte[10]);
ServerTests.cs (1)
133var input = await new StreamReader(httpContext.Request.Body).ReadToEndAsync();
Microsoft.AspNetCore.Server.Kestrel.Core.Tests (4)
src\Servers\Kestrel\shared\test\TestApp.cs (4)
22await request.Body.FillBufferUntilEndAsync(buffer).DefaultTimeout(); 32await request.Body.CopyToAsync(data); 52await request.Body.FillBufferUntilEndAsync(buffer).DefaultTimeout(); 66await request.Body.CopyToAsync(data);
Microsoft.AspNetCore.SpaServices.Extensions (1)
Proxying\SpaProxy.cs (1)
140var streamContent = new StreamContent(request.Body);
Microsoft.AspNetCore.TestHost.Tests (10)
ClientHandlerTests.cs (2)
56Assert.NotNull(context.Request.Body); 353int read = await context.Request.Body.ReadAsync(new byte[100], 0, 100);
HttpContextBuilderTests.cs (1)
39Assert.NotNull(context.Request.Body);
TestClientTests.cs (6)
90var content = await new StreamReader(ctx.Request.Body).ReadToEndAsync(); 110await ctx.Response.WriteAsync(await new StreamReader(ctx.Request.Body).ReadToEndAsync() + " POST Response"); 184var requestString = await new StreamReader(ctx.Request.Body).ReadToEndAsync(); 280var serverLength = await ctx.Request.Body.ReadAsync(serverBuffer); 288await ctx.Request.Body.ReadAsync(serverBuffer); 412var pendingReadTask = ctx.Request.Body.ReadAsync(new byte[1024], 0, 1024);
TestServerTests.cs (1)
214using (var sr = new StreamReader(context.Request.Body))
RequestDecompressionSample (1)
Startup.cs (1)
23using var reader = new StreamReader(context.Request.Body);
Sockets.FunctionalTests (11)
src\Servers\Kestrel\shared\test\TestApp.cs (4)
22await request.Body.FillBufferUntilEndAsync(buffer).DefaultTimeout(); 32await request.Body.CopyToAsync(data); 52await request.Body.FillBufferUntilEndAsync(buffer).DefaultTimeout(); 66await request.Body.CopyToAsync(data);
src\Servers\Kestrel\test\FunctionalTests\MaxRequestBufferSizeTests.cs (2)
352bytesRead += await context.Request.Body.ReadAsync(buffer, bytesRead, buffer.Length - bytesRead); 358if (await context.Request.Body.ReadAsync(new byte[1], 0, 1) != 0)
src\Servers\Kestrel\test\FunctionalTests\RequestTests.cs (4)
92while ((received = await context.Request.Body.ReadAsync(receivedBytes, 0, receivedBytes.Length)) > 0) 552await context.Request.Body.ReadAsync(new byte[1], 0, 1); 873var readTask = request.Body.CopyToAsync(Stream.Null); 1059await context.Request.Body.CopyToAsync(Stream.Null);
src\Servers\Kestrel\test\FunctionalTests\ResponseTests.cs (1)
786await context.Request.Body.CopyToAsync(context.Response.Body);
Wasm.Performance.Driver (1)
BenchmarkResultsStartup.cs (1)
22var result = await JsonSerializer.DeserializeAsync<BenchmarkResult>(context.Request.Body, new JsonSerializerOptions