1 override of Body
Microsoft.AspNetCore.Http (1)
Internal\DefaultHttpResponse.cs (1)
67public override Stream Body
262 writes to Body
InMemory.FunctionalTests (5)
RequestTests.cs (1)
43context.Response.Body = new MemoryStream();
ResponseTests.cs (4)
4305httpContext.Response.Body = new MemoryStream(); 4308httpContext.Response.Body = new MemoryStream(); 4338httpContext.Response.Body = new MemoryStream(); 4345httpContext.Response.Body = oldBody;
InProcessWebSite (2)
src\Servers\IIS\IIS\test\testassets\InProcessWebSite\Startup.cs (2)
348ctx.Response.Body = body; 350ctx.Response.Body = originalBody;
Microsoft.AspNetCore.Components.Endpoints.Tests (13)
EndpointHtmlRendererTest.cs (3)
886httpContext.Response.Body = bodyStream; 915httpContext.Response.Body = bodyStream; 1008httpContext.Response.Body = bodyStream;
RazorComponentResultTest.cs (10)
58httpContext.Response.Body = responseBody; 80httpContext.Response.Body = responseBody; 98httpContext.Response.Body = responseBody; 129httpContext.Response.Body = responseBody; 160httpContext.Response.Body = responseBody; 188httpContext.Response.Body = responseBody; 214httpContext.Response.Body = responseBody; 264httpContext.Response.Body = responseBody; 316httpContext.Response.Body = responseBody; 419httpContext.Response.Body = responseBody;
Microsoft.AspNetCore.Diagnostics.Tests (2)
ExceptionHandlerTest.cs (2)
139response.Body = bufferingStream; 147response.Body = originalResponseBody;
Microsoft.AspNetCore.Grpc.JsonTranscoding.Tests (2)
Infrastructure\TestHelpers.cs (1)
29httpContext.Response.Body = bodyStream ?? new MemoryStream();
JsonTranscodingServerCallContextTests.cs (1)
66httpContext.Response.Body = new MemoryStream();
Microsoft.AspNetCore.Hosting.Tests (1)
WebHostBuilderTests.cs (1)
1519httpContext.Response.Body = new MemoryStream();
Microsoft.AspNetCore.Http.Abstractions.Tests (2)
HttpResponseWritingExtensionsTests.cs (2)
36context.Response.Body = outputStream; 87context.Response.Body = new MemoryStream();
Microsoft.AspNetCore.Http.Connections.Tests (37)
HttpConnectionDispatcherTests.cs (32)
68context.Response.Body = ms; 92context.Response.Body = ms; 118context.Response.Body = ms; 155context.Response.Body = ms; 183context.Response.Body = ms; 221context.Response.Body = responseBody; 270context.Response.Body = ms; 301context.Response.Body = strm; 343context.Response.Body = strm; 381context.Response.Body = strm; 420context.Response.Body = strm; 459context.Response.Body = strm; 522context.Response.Body = strm; 591context.Response.Body = responseBody; 756context.Response.Body = responseBody; 854context.Response.Body = strm; 900context.Response.Body = responseBody; 930context.Response.Body = strm; 1295context.Response.Body = new BlockingStream(sync); 1333context.Response.Body = new BlockingStream(sync, isSSE: true); 2038deleteContext.Response.Body = ms; 2239context.Response.Body = ms; 2249context.Response.Body = ms; 2272context.Response.Body = ms; 2298context.Response.Body = ms; 2327context.Response.Body = ms; 2356context.Response.Body = ms; 2567context.Response.Body = responseBody; 2627context.Response.Body = responseBody; 2684context.Response.Body = responseBody; 3692context.Response.Body = strm; 3745context.Response.Body = new MemoryStream();
LongPollingTests.cs (2)
73context.Response.Body = ms; 96context.Response.Body = ms;
ServerSentEventsTests.cs (3)
71context.Response.Body = ms; 93context.Response.Body = ms; 122context.Response.Body = ms;
Microsoft.AspNetCore.Http.Extensions.Tests (50)
HttpResponseJsonExtensionsTests.cs (21)
26context.Response.Body = body; 45context.Response.Body = body; 63context.Response.Body = body; 96context.Response.Body = body; 113context.Response.Body = body; 127context.Response.Body = new TestStream(); 147context.Response.Body = body; 167context.Response.Body = body; 186context.Response.Body = body; 204context.Response.Body = body; 216context.Response.Body = body; 228context.Response.Body = body; 248context.Response.Body = body; 265context.Response.Body = body; 290context.Response.Body = body; 316context.Response.Body = body; 350context.Response.Body = body; 383context.Response.Body = body; 417context.Response.Body = body; 451context.Response.Body = body; 472context.Response.Body = body;
ProblemDetailsDefaultWriterTest.cs (1)
680Response = { Body = body, StatusCode = statusCode },
ProblemDetailsServiceTest.cs (6)
26Response = { Body = stream, StatusCode = StatusCodes.Status400BadRequest }, 52Response = { Body = stream, StatusCode = StatusCodes.Status400BadRequest }, 71Response = { Body = stream, StatusCode = StatusCodes.Status400BadRequest }, 87Response = { Body = stream, StatusCode = StatusCodes.Status400BadRequest }, 102Response = { Body = stream, StatusCode = StatusCodes.Status400BadRequest }, 122Response = { Body = stream, StatusCode = StatusCodes.Status400BadRequest },
RequestDelegateFactoryTests.cs (17)
1347httpContext.Response.Body = responseBodyStream; 1380httpContext.Response.Body = responseBodyStream; 1409httpContext.Response.Body = responseBodyStream; 1476httpContext.Response.Body = responseBodyStream; 1515httpContext.Response.Body = responseBodyStream; 1560httpContext.Response.Body = responseBodyStream; 1773httpContext.Response.Body = responseBodyStream; 1803httpContext.Response.Body = responseBodyStream; 1833httpContext.Response.Body = responseBodyStream; 1863httpContext.Response.Body = responseBodyStream; 1903httpContext.Response.Body = responseBodyStream; 2159httpContext.Response.Body = responseBodyStream; 2196httpContext.Response.Body = responseBodyStream; 2278httpContext.Response.Body = responseBodyStream; 2373httpContext.Response.Body = responseBodyStream; 2407httpContext.Response.Body = responseBodyStream; 2492httpContext.Response.Body = responseBodyStream;
RequestDelegateGenerator\RequestDelegateCreationTestBase.cs (1)
203httpContext.Response.Body = outStream;
RequestDelegateGenerator\RequestDelegateCreationTests.QueryParameters.cs (1)
50httpContext.Response.Body = responseBodyStream;
SendFileResponseExtensionsTests.cs (3)
40response.Body = body; 53response.Body = body; 80response.Body = body;
Microsoft.AspNetCore.Http.Microbenchmarks (1)
src\Http\Http.Extensions\test\RequestDelegateGenerator\RequestDelegateCreationTestBase.cs (1)
203httpContext.Response.Body = outStream;
Microsoft.AspNetCore.Http.Results.Tests (60)
AcceptedAtRouteOfTResultTests.cs (1)
43httpContext.Response.Body = stream;
AcceptedOfTResultTests.cs (1)
22httpContext.Response.Body = stream;
BadRequestOfTResultTests.cs (1)
73Body = stream,
ConflictOfTResultTests.cs (1)
72Body = stream,
ContentResultTests.cs (1)
113httpContext.Response.Body = memoryStream;
CreatedAtRouteOfTResultTests.cs (1)
183httpContext.Response.Body = new MemoryStream();
CreatedAtRouteResultTests.cs (1)
129httpContext.Response.Body = new MemoryStream();
CreatedOfTResultTests.cs (2)
85httpContext.Response.Body = stream; 180httpContext.Response.Body = new MemoryStream();
CreatedResultTests.cs (1)
117httpContext.Response.Body = new MemoryStream();
EmptyResultTests.cs (1)
41httpContext.Response.Body = new MemoryStream();
HttpResultsHelperTests.cs (1)
238Body = stream,
InternalServerErrorOfTResultTests.cs (1)
73Body = stream,
JsonResultTests.cs (5)
64Body = stream, 92Body = stream, 125Body = stream, 154Body = stream, 186Body = stream,
NotFoundOfTResultTests.cs (1)
143httpContext.Response.Body = new MemoryStream();
NotFoundResultTests.cs (1)
92httpContext.Response.Body = new MemoryStream();
OkOfTResultTests.cs (1)
54Body = stream,
ProblemResultTests.cs (5)
28Body = stream, 60Body = stream, 89Body = stream, 121Body = stream, 153Body = stream,
PushStreamResultTests.cs (1)
22httpContext.Response.Body = ms;
src\Shared\ResultsTests\FileContentResultTestBase.cs (10)
35httpContext.Response.Body = outStream; 69httpContext.Response.Body = new MemoryStream(); 109httpContext.Response.Body = new MemoryStream(); 148httpContext.Response.Body = new MemoryStream(); 182httpContext.Response.Body = new MemoryStream(); 213httpContext.Response.Body = new MemoryStream(); 244httpContext.Response.Body = new MemoryStream(); 281httpContext.Response.Body = new MemoryStream(); 315httpContext.Response.Body = new MemoryStream(); 343httpContext.Response.Body = outStream;
src\Shared\ResultsTests\FileStreamResultTestBase.cs (12)
47httpContext.Response.Body = new MemoryStream(); 90httpContext.Response.Body = new MemoryStream(); 131httpContext.Response.Body = new MemoryStream(); 168httpContext.Response.Body = new MemoryStream(); 201httpContext.Response.Body = new MemoryStream(); 234httpContext.Response.Body = new MemoryStream(); 273httpContext.Response.Body = new MemoryStream(); 309httpContext.Response.Body = new MemoryStream(); 350httpContext.Response.Body = new MemoryStream(); 384httpContext.Response.Body = outStream; 409httpContext.Response.Body = outStream; 430httpContext.Response.Body = outStream;
src\Shared\ResultsTests\PhysicalFileResultTestBase.cs (3)
192httpContext.Response.Body = new MemoryStream(); 221httpContext.Response.Body = new MemoryStream(); 248httpContext.Response.Body = new MemoryStream();
src\Shared\ResultsTests\VirtualFileResultTestBase.cs (3)
228httpContext.Response.Body = new MemoryStream(); 234httpContext.Response.Body = new MemoryStream(); 453httpContext.Response.Body = new MemoryStream();
UnprocessableEntityOfTResultTests.cs (1)
71Body = stream,
Utf8ContentResultTests.cs (2)
37context.Response.Body = ms; 55context.Response.Body = ms;
ValidationProblemResultTests.cs (2)
31Body = stream, 64Body = stream,
Microsoft.AspNetCore.Http.Tests (3)
Internal\DefaultHttpResponseTests.cs (3)
88context.Response.Body = replacementStream; 93context.Response.Body = originalStream; 167context.Response.Body = mock;
Microsoft.AspNetCore.HttpLogging (1)
HttpLoggingMiddleware.cs (1)
209response.Body = responseBufferingStream;
Microsoft.AspNetCore.Mvc.Core.Test (40)
ContentResultTest.cs (2)
129httpContext.Response.Body = memoryStream; 232httpContext.Response.Body = memoryStream;
CreatedAtActionResultTests.cs (1)
79httpContext.Response.Body = new MemoryStream();
CreatedAtRouteResultTests.cs (1)
93httpContext.Response.Body = new MemoryStream();
CreatedResultTests.cs (1)
126httpContext.Response.Body = new MemoryStream();
Filters\MiddlewareFilterTest.cs (1)
262httpContext.Response.Body = new MemoryStream();
Formatters\JsonOutputFormatterTestBase.cs (1)
170httpContext.Response.Body = responseStream ?? new MemoryStream();
HttpNotFoundObjectResultTest.cs (1)
59httpContext.Response.Body = new MemoryStream();
Infrastructure\ControllerActionInvokerTest.cs (1)
1716httpContext.Response.Body = new MemoryStream();
Infrastructure\DefaultApiProblemDetailsWriterTest.cs (1)
207Response = { Body = body, StatusCode = statusCode },
Infrastructure\JsonResultExecutorTestBase.cs (2)
280context.HttpContext.Response.Body = stream.Object; 481httpContext.Response.Body = new MemoryStream();
src\Shared\ResultsTests\FileContentResultTestBase.cs (10)
35httpContext.Response.Body = outStream; 69httpContext.Response.Body = new MemoryStream(); 109httpContext.Response.Body = new MemoryStream(); 148httpContext.Response.Body = new MemoryStream(); 182httpContext.Response.Body = new MemoryStream(); 213httpContext.Response.Body = new MemoryStream(); 244httpContext.Response.Body = new MemoryStream(); 281httpContext.Response.Body = new MemoryStream(); 315httpContext.Response.Body = new MemoryStream(); 343httpContext.Response.Body = outStream;
src\Shared\ResultsTests\FileStreamResultTestBase.cs (12)
47httpContext.Response.Body = new MemoryStream(); 90httpContext.Response.Body = new MemoryStream(); 131httpContext.Response.Body = new MemoryStream(); 168httpContext.Response.Body = new MemoryStream(); 201httpContext.Response.Body = new MemoryStream(); 234httpContext.Response.Body = new MemoryStream(); 273httpContext.Response.Body = new MemoryStream(); 309httpContext.Response.Body = new MemoryStream(); 350httpContext.Response.Body = new MemoryStream(); 384httpContext.Response.Body = outStream; 409httpContext.Response.Body = outStream; 430httpContext.Response.Body = outStream;
src\Shared\ResultsTests\PhysicalFileResultTestBase.cs (3)
192httpContext.Response.Body = new MemoryStream(); 221httpContext.Response.Body = new MemoryStream(); 248httpContext.Response.Body = new MemoryStream();
src\Shared\ResultsTests\VirtualFileResultTestBase.cs (3)
228httpContext.Response.Body = new MemoryStream(); 234httpContext.Response.Body = new MemoryStream(); 453httpContext.Response.Body = new MemoryStream();
Microsoft.AspNetCore.Mvc.Formatters.Xml.Test (8)
XmlDataContractSerializerOutputFormatterTest.cs (4)
355response.Body = FlushReportingStream.GetThrowingStream(); 735outputFormatterContext.HttpContext.Response.Body = body; 772outputFormatterContext.HttpContext.Response.Body = body; 806httpContext.Response.Body = new MemoryStream();
XmlSerializerOutputFormatterTest.cs (4)
409response.Body = Stream.Null; 517outputFormatterContext.HttpContext.Response.Body = body; 554outputFormatterContext.HttpContext.Response.Body = body; 588httpContext.Response.Body = new MemoryStream();
Microsoft.AspNetCore.Mvc.NewtonsoftJson.Test (4)
JsonResultTest.cs (1)
42httpContext.Response.Body = new MemoryStream();
src\Mvc\Mvc.Core\test\Formatters\JsonOutputFormatterTestBase.cs (1)
170httpContext.Response.Body = responseStream ?? new MemoryStream();
src\Mvc\Mvc.Core\test\Infrastructure\JsonResultExecutorTestBase.cs (2)
280context.HttpContext.Response.Body = stream.Object; 481httpContext.Response.Body = new MemoryStream();
Microsoft.AspNetCore.Mvc.ViewFeatures.Test (10)
ViewComponentResultTest.cs (3)
417httpContext.Response.Body = new MemoryStream(); 459httpContext.Response.Body = new MemoryStream(); 691httpContext.Response.Body = new MemoryStream();
ViewExecutorTest.cs (7)
95context.Response.Body = stream.Object; 134context.Response.Body = memoryStream; 189context.Response.Body = memoryStream; 226context.Response.Body = memoryStream; 261context.Response.Body = memoryStream; 309context.Response.Body = memoryStream; 350context.Response.Body = stream.Object;
Microsoft.AspNetCore.OpenApi.Tests (4)
Extensions\OpenApiEndpointRouteBuilderExtensionsTests.cs (4)
59context.Response.Body = responseBodyStream; 90context.Response.Body = responseBodyStream; 121context.Response.Body = responseBodyStream; 150context.Response.Body = responseBodyStream;
Microsoft.AspNetCore.OutputCaching.Tests (3)
OutputCacheMiddlewareTests.cs (3)
885context1.HttpContext.Response.Body = memoryStream1; 890context2.HttpContext.Response.Body = memoryStream2; 1046requestContext.HttpContext.Response.Body = responseStream;
Microsoft.AspNetCore.Owin (1)
OwinEnvironment.cs (1)
66{ OwinConstants.ResponseBody, new FeatureMap<IHttpResponseBodyFeature>(feature => feature.Stream, () => Stream.Null, (feature, value) => context.Response.Body = (Stream)value) }, // DefaultHttpResponse.Body.Set has built in logic to handle replacing the feature.
Microsoft.AspNetCore.Owin.Tests (1)
OwinEnvironmentTests.cs (1)
31context.Response.Body = Stream.Null;
Microsoft.AspNetCore.ResponseCaching (2)
ResponseCachingMiddleware.cs (2)
410context.HttpContext.Response.Body = context.ResponseCachingStream; 422context.HttpContext.Response.Body = context.OriginalResponseStream;
Microsoft.AspNetCore.ResponseCompression.Tests (1)
ResponseCompressionMiddlewareTest.cs (1)
1191context.Response.Body = new NoSyncWrapperStream(context.Response.Body);
Microsoft.AspNetCore.Routing.Tests (8)
Builder\RequestDelegateEndpointRouteBuilderExtensionsTest.cs (6)
84httpContext.Response.Body = responseBodyStream; 117httpContext.Response.Body = responseBodyStream; 152httpContext.Response.Body = responseBodyStream; 182httpContext.Response.Body = responseBodyStream; 231httpContext.Response.Body = responseBodyStream; 266httpContext.Response.Body = responseBodyStream;
Builder\RouteHandlerEndpointRouteBuilderExtensionsTest.cs (2)
899httpContext.Response.Body = outStream; 976httpContext.Response.Body = outStream;
Microsoft.AspNetCore.StaticFiles.Tests (1)
StaticFileContextTest.cs (1)
132httpContext.Response.Body = body;
568 references to Body
Aspire.Dashboard (1)
Otlp\Http\OtlpHttpEndpointsBuilder.cs (1)
158await ms.CopyToAsync(httpContext.Response.Body).ConfigureAwait(false);
Benchmarks (2)
StartupUsingEndpointRouting.cs (1)
34return response.Body.WriteAsync(_helloWorldPayload, 0, payloadLength);
StartupUsingRouter.cs (1)
28return response.Body.WriteAsync(_helloWorldPayload, 0, payloadLength);
HealthChecksSample (2)
DbContextHealthStartup.cs (2)
51await context.Response.Body.FlushAsync(); 63await context.Response.Body.FlushAsync();
HttpStress (4)
Program.cs (4)
433await context.Response.Body.FlushAsync(); 476await s.CopyToAsync(context.Response.Body); 481await context.Request.Body.CopyToAsync(context.Response.Body); 489await context.Response.Body.WriteAsync(buffer);
IIS.Microbenchmarks (1)
PlaintextBenchmark.cs (1)
70return response.Body.WriteAsync(_helloWorldPayload, 0, payloadLength);
IIS.Tests (7)
ClientDisconnectTests.cs (3)
38await ctx.Response.Body.WriteAsync(data); 74await ctx.Response.Body.WriteAsync(data, ctx.RequestAborted); 157await ctx.Response.Body.WriteAsync(data, cancellationTokenSource.Token);
HttpBodyControlFeatureTests.cs (1)
30ctx.Response.Body.Write(new byte[10]);
ResponseAbortTests.cs (2)
45await ctx.Response.Body.FlushAsync(); 107await ctx.Response.Body.WriteAsync(new byte[10]);
ResponseBodySizeTests.cs (1)
23await ctx.Response.Body.WriteAsync(buffer, 0, buffer.Length);
InMemory.FunctionalTests (86)
ChunkedRequestTests.cs (8)
34await response.Body.WriteAsync(buffer, 0, count); 67await response.Body.WriteAsync(bytes, 0, bytes.Length); 184await response.Body.WriteAsync(Encoding.ASCII.GetBytes("Hello World"), 0, 11); 297await response.Body.WriteAsync(Encoding.ASCII.GetBytes("Hello World"), 0, 11); 428await response.Body.WriteAsync(Encoding.ASCII.GetBytes("Hello World"), 0, 11); 603await response.Body.WriteAsync(Encoding.ASCII.GetBytes("Hello World"), 0, 11); 676await response.Body.WriteAsync(Encoding.ASCII.GetBytes("Hello World"), 0, 11); 720await response.Body.WriteAsync(Encoding.ASCII.GetBytes("Hello World"), 0, 11);
ChunkedResponseTests.cs (1)
1158await response.Body.WriteAsync(Encoding.ASCII.GetBytes("hello, world"));
ConnectionMiddlewareTests.cs (1)
279await context.Response.Body.FlushAsync();
Http2\Http2ConnectionTests.cs (21)
61return c.Response.Body.WriteAsync(new byte[1]).AsTask(); 93await c.Response.Body.FlushAsync(); 96await c.Response.Body.WriteAsync(new byte[65540]); 1181await context.Response.Body.WriteAsync(data, 0, read); 1913await context.Response.Body.WriteAsync(_maxData, 0, _maxData.Length); 2069await context.Response.Body.WriteAsync(data); 3213await context.Response.Body.FlushAsync(); 3217await context.Response.Body.WriteAsync(_maxData, 0, _maxData.Length); 3220await context.Response.Body.WriteAsync(_maxData, 0, remainingBytesBeforeBackpressure + 1); 3331await context.Response.Body.WriteAsync(_helloWorldBytes, 0, _helloWorldBytes.Length); 3892return context.Response.Body.WriteAsync(new byte[payloadLength], 0, payloadLength); 3943return context.Response.Body.WriteAsync(new byte[clientMaxFrame], 0, clientMaxFrame); 4236await context.Response.Body.FlushAsync(); 4240await context.Response.Body.WriteAsync(_maxData, 0, _maxData.Length); 4243await context.Response.Body.WriteAsync(_maxData, 0, remainingBytesBeforeBackpressure + 1); 4338await context.Response.Body.WriteAsync(_helloWorldBytes, 0, _helloWorldBytes.Length); 4584await context.Response.Body.FlushAsync(); 4589await context.Response.Body.WriteAsync(_maxData, 0, _maxData.Length); 4593var lastWriteTask = context.Response.Body.WriteAsync(_maxData, 0, _maxData.Length); 4764await context.Response.Body.WriteAsync(new byte[windowSize - 1], 0, windowSize - 1); 4766await context.Response.Body.WriteAsync(new byte[windowSize], 0, windowSize);
Http2\Http2StreamTests.cs (13)
1643await context.Response.Body.FlushAsync(); 3193await context.Response.Body.WriteAsync(new byte[10], 0, 10); 3259await context.Response.Body.WriteAsync(new byte[10], 0, 10); 3302await context.Response.Body.WriteAsync(new byte[10], 0, 10); 3349await context.Response.Body.WriteAsync(new byte[10], 0, 10); 3386await context.Response.Body.WriteAsync(new byte[10], 0, 10); 3391await context.Response.Body.WriteAsync(new byte[11], 0, 11); 3488await context.Response.Body.WriteAsync(new byte[windowSize + 1], 0, windowSize + 1); 3489context.Response.Body.Write(new byte[1], 0, 1); 3830await context.Response.Body.FlushAsync(); // https://github.com/aspnet/KestrelHttpServer/issues/3031 4385await response.Body.WriteAsync(Encoding.ASCII.GetBytes("hello, world")); 4535await httpContext.Response.Body.WriteAsync(Encoding.ASCII.GetBytes("hello, world")); 4585await response.Body.WriteAsync(Encoding.ASCII.GetBytes("hello, world\r\n"));
Http2\Http2TestBase.cs (5)
246await context.Response.Body.WriteAsync(data.ToArray(), 0, data.Count); 256await context.Response.Body.WriteAsync(buffer, 0, received); 267await context.Response.Body.WriteAsync(buffer, 0, received); 327await context.Response.Body.FlushAsync(); 347await context.Response.Body.WriteAsync(new byte[1], 0, 1);
Http2\Http2TimeoutTests.cs (1)
339var writeTask = context.Response.Body.WriteAsync(buffer, 0, received);
Http2\Http2WebSocketTests.cs (3)
456var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => context.Response.Body.WriteAsync(new byte[1] { 0x00 }).AsTask()); 465ex = await Assert.ThrowsAsync<InvalidOperationException>(() => context.Response.Body.WriteAsync(new byte[1] { 0x00 }).AsTask()); 533await context.Response.Body.WriteAsync(new byte[1] { 0x01 });
Http3\Http3ConnectionTests.cs (3)
46await context.Response.Body.WriteAsync(buffer, 0, received); 86await context.Response.Body.WriteAsync(buffer, 0, received); 149await context.Response.Body.WriteAsync(buffer, 0, received);
Http3\Http3StreamTests.cs (2)
2014await c.Response.Body.FlushAsync(); 2837await context.Response.Body.WriteAsync(buffer.AsMemory(0, 100));
Http3\Http3TestBase.cs (2)
70await context.Response.Body.WriteAsync(buffer, 0, received); 89await context.Response.Body.WriteAsync(new byte[1], 0, 1);
Http3\Http3TimeoutTests.cs (2)
429await context.Response.Body.FlushAsync(); 436var writeTask = context.Response.Body.WriteAsync(buffer, 0, received);
HttpsConnectionMiddlewareTests.cs (1)
1496await response.Body.WriteAsync(buffer, 0, count);
KeepAliveTimeoutTests.cs (1)
261var responseStream = httpContext.Response.Body;
KestrelMetricsTests.cs (1)
926await response.Body.WriteAsync(buffer, 0, buffer.Length);
MaxRequestBodySizeTests.cs (1)
226await context.Response.Body.WriteAsync(buffer, 0, 1);
RequestTests.cs (4)
37if (context.Response.Body is MemoryStream) 1420await context.Response.Body.WriteAsync(request, 0, request.Length); 1713await context.Response.Body.WriteAsync(buffer, 0, 6); 1756await context.Response.Body.WriteAsync(buffer, 0, 5);
ResponseTests.cs (13)
1766await httpContext.Response.Body.WriteAsync(new Memory<byte>(response, 0, response.Length)); 1853await httpContext.Response.Body.WriteAsync(new Memory<byte>(response, 0, response.Length / 2)); 1854await httpContext.Response.Body.WriteAsync(new Memory<byte>(response, response.Length / 2, response.Length - response.Length / 2)); 3424var ioEx = Assert.Throws<InvalidOperationException>(() => context.Response.Body.Write(Encoding.ASCII.GetBytes("What!?"), 0, 6)); 3426await context.Response.Body.WriteAsync(Encoding.ASCII.GetBytes("Hello1"), 0, 6); 3452context.Response.Body.Write(Encoding.ASCII.GetBytes("Hello1"), 0, 6); 3483context.Response.Body.Write(Encoding.ASCII.GetBytes("Hello!"), 0, 6); 3520var ioEx = Assert.Throws<InvalidOperationException>(() => context.Response.Body.Write(Encoding.ASCII.GetBytes("What!?"), 0, 6)); 3750await httpContext.Response.Body.WriteAsync(Encoding.ASCII.GetBytes("hello, world")); 3786await response.Body.WriteAsync(Encoding.ASCII.GetBytes("hello, world\r\n")); 4337var oldBody = httpContext.Response.Body; 4341await httpContext.Response.Body.WriteAsync(new byte[1]); 4343Assert.Equal(2, httpContext.Response.Body.Length);
src\Servers\Kestrel\shared\test\TestApp.cs (2)
23await response.Body.WriteAsync(buffer, 0, buffer.Length); 36await response.Body.WriteAsync(bytes, 0, bytes.Length);
UpgradeTests.cs (1)
31var ex = await Assert.ThrowsAsync<InvalidOperationException>(() => context.Response.Body.WriteAsync(new byte[1], 0, 1));
InProcessWebSite (19)
src\Servers\IIS\IIS\test\testassets\InProcessWebSite\Startup.cs (19)
212await context.Response.Body.WriteAsync(new byte[100], 0, 100); 345var originalBody = ctx.Response.Body; 349Assert.Same(body, ctx.Response.Body); 649await ctx.Response.Body.FlushAsync(); 665await ctx.Response.Body.FlushAsync(); 676await ctx.Response.Body.FlushAsync(); 697await ctx.Response.Body.FlushAsync(); 722await ctx.Response.Body.WriteAsync(data, 0, data.Length); 742await ctx.Response.Body.FlushAsync(); 744await ctx.Response.Body.FlushAsync(); 769await ctx.Request.Body.CopyToAsync(ctx.Response.Body); 886await ctx.Response.Body.WriteAsync(new byte[1], -1, 0); 897await ctx.Response.Body.WriteAsync(new byte[1], 2, 0); 908await ctx.Response.Body.WriteAsync(new byte[1], 0, -1); 919await ctx.Response.Body.WriteAsync(new byte[1], 0, -1); 930await ctx.Response.Body.WriteAsync(new byte[3], 1, 3); 945await ctx.Response.Body.WriteAsync(null, 0, 0); 949await ctx.Response.Body.WriteAsync(null, 0, 0); 1057await ctx.Response.Body.FlushAsync();
Interop.FunctionalTests (13)
Http3\Http3RequestTests.cs (12)
238await context.Response.Body.WriteAsync(TestData); 242await context.Response.Body.WriteAsync(TestData); 332await context.Response.Body.WriteAsync(data); 407await context.Response.Body.WriteAsync(data); 602await context.Response.Body.WriteAsync(new byte[16]); 667writeAsyncTask.SetResult(context.Response.Body.WriteAsync(TestData).AsTask()); 714await context.Response.Body.WriteAsync(data); 983var responseBody = context.Response.Body; 1300var responseBody = context.Response.Body; 2006await context.Response.Body.FlushAsync(); 2122await context.Response.Body.FlushAsync(); 2128await context.Response.Body.WriteAsync(data);
HttpClientHttp2InteropTests.cs (1)
120await content.CopyToAsync(context.Response.Body).DefaultTimeout();
LargeResponseApp (1)
Startup.cs (1)
36await context.Response.Body.WriteAsync(_chunk, 0, _chunkSize).ConfigureAwait(false);
Microsoft.AspNetCore.Authentication.OpenIdConnect (2)
OpenIdConnectHandler.cs (2)
298await Response.Body.WriteAsync(buffer); 546await Response.Body.WriteAsync(buffer);
Microsoft.AspNetCore.Authentication.Test (3)
CookieTests.cs (1)
1900return res.Body.WriteAsync(xmlBytes, 0, xmlBytes.Length);
TestExtensions.cs (2)
61return res.Body.WriteAsync(xmlBytes, 0, xmlBytes.Length); 78return res.Body.WriteAsync(xmlBytes, 0, xmlBytes.Length);
Microsoft.AspNetCore.Components.Endpoints (6)
Builder\ResourceCollectionUrlEndpoint.cs (4)
187await context.Response.Body.WriteAsync(_gzipContent); 194await context.Response.Body.WriteAsync(_content); 201await context.Response.Body.WriteAsync(_content); 209await context.Response.Body.WriteAsync(_gzipContent);
RazorComponentEndpointInvoker.cs (1)
85await using var writer = new HttpResponseStreamWriter(context.Response.Body, Encoding.UTF8, defaultBufferSize, ArrayPool<byte>.Shared, ArrayPool<char>.Shared);
Results\RazorComponentResultExecutor.cs (1)
64await using var writer = new HttpResponseStreamWriter(httpContext.Response.Body, Encoding.UTF8, defaultBufferSize, ArrayPool<byte>.Shared, ArrayPool<char>.Shared);
Microsoft.AspNetCore.Components.Endpoints.Tests (3)
EndpointHtmlRendererTest.cs (3)
899httpContext.Response.Body.Position = 0; 928httpContext.Response.Body.Position = 0; 1043httpContext.Response.Body.Position = 0;
Microsoft.AspNetCore.CookiePolicy.Test (2)
CookieConsentTests.cs (2)
336var reader = new StreamReader(httpContext.Response.Body); 487var reader = new StreamReader(httpContext.Response.Body);
Microsoft.AspNetCore.Diagnostics (2)
src\Shared\Diagnostics\BaseView.cs (1)
66Output = new StreamWriter(Response.Body, Encoding.UTF8, 4096, leaveOpen: true);
src\Shared\RazorViews\BaseView.cs (1)
91await buffer.CopyToAsync(Response.Body);
Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore (2)
src\Shared\Diagnostics\BaseView.cs (1)
66Output = new StreamWriter(Response.Body, Encoding.UTF8, 4096, leaveOpen: true);
src\Shared\RazorViews\BaseView.cs (1)
91await buffer.CopyToAsync(Response.Body);
Microsoft.AspNetCore.Diagnostics.HealthChecks (3)
HealthCheckResponseWriters.cs (3)
21HealthStatus.Degraded => httpContext.Response.Body.WriteAsync(DegradedBytes.AsMemory()).AsTask(), 22HealthStatus.Healthy => httpContext.Response.Body.WriteAsync(HealthyBytes.AsMemory()).AsTask(), 23HealthStatus.Unhealthy => httpContext.Response.Body.WriteAsync(UnhealthyBytes.AsMemory()).AsTask(),
Microsoft.AspNetCore.Diagnostics.Tests (4)
ExceptionHandlerTest.cs (4)
137var originalResponseBody = response.Body; 151await bufferingStream.CopyToAsync(response.Body); 160Assert.True(httpContext.Response.Body.CanSeek); 161Assert.Equal(0, httpContext.Response.Body.Position);
Microsoft.AspNetCore.Grpc.JsonTranscoding (5)
Internal\CallHandlers\UnaryServerCallHandler.cs (1)
49await serverCallContext.HttpContext.Response.Body.WriteAsync(httpBody.Data.Memory);
Internal\HttpContextStreamWriter.cs (2)
89await _context.HttpContext.Response.Body.WriteAsync(httpBody.Data.Memory, cancellationToken); 97await _context.HttpContext.Response.Body.WriteAsync(GrpcProtocolConstants.StreamingDelimiter, cancellationToken);
Internal\JsonRequestHelpers.cs (1)
168var (stream, usesTranscodingStream) = GetStream(response.Body, encoding);
Internal\JsonTranscodingServerCallContext.cs (1)
132await HttpContext.Response.Body.WriteAsync(GrpcProtocolConstants.StreamingDelimiter);
Microsoft.AspNetCore.Grpc.JsonTranscoding.Tests (42)
UnaryServerCallHandlerTests.cs (42)
80httpContext.Response.Body.Seek(0, SeekOrigin.Begin); 81using var responseJson = JsonDocument.Parse(httpContext.Response.Body); 118httpContext.Response.Body.Seek(0, SeekOrigin.Begin); 119using var responseJson = JsonDocument.Parse(httpContext.Response.Body); 149httpContext.Response.Body.Seek(0, SeekOrigin.Begin); 150var sr = new StreamReader(httpContext.Response.Body); 178httpContext.Response.Body.Seek(0, SeekOrigin.Begin); 179using var responseJson = JsonDocument.Parse(httpContext.Response.Body); 715httpContext.Response.Body.Seek(0, SeekOrigin.Begin); 716using var responseJson = JsonDocument.Parse(httpContext.Response.Body); 747httpContext.Response.Body.Seek(0, SeekOrigin.Begin); 748using var responseJson = JsonDocument.Parse(httpContext.Response.Body); 785httpContext.Response.Body.Seek(0, SeekOrigin.Begin); 786using var responseJson = JsonDocument.Parse(httpContext.Response.Body); 815httpContext.Response.Body.Seek(0, SeekOrigin.Begin); 816using var responseJson = JsonDocument.Parse(httpContext.Response.Body); 839httpContext.Response.Body.Seek(0, SeekOrigin.Begin); 840using var responseJson = JsonDocument.Parse(httpContext.Response.Body); 864httpContext.Response.Body.Seek(0, SeekOrigin.Begin); 865using var responseJson = JsonDocument.Parse(httpContext.Response.Body); 931httpContext.Response.Body.Seek(0, SeekOrigin.Begin); 932using var responseJson = JsonDocument.Parse(httpContext.Response.Body); 1009httpContext.Response.Body.Seek(0, SeekOrigin.Begin); 1010using var responseJson = JsonDocument.Parse(httpContext.Response.Body); 1051httpContext.Response.Body.Seek(0, SeekOrigin.Begin); 1052using var responseJson = JsonDocument.Parse(httpContext.Response.Body); 1081httpContext.Response.Body.Seek(0, SeekOrigin.Begin); 1082using var responseJson = JsonDocument.Parse(httpContext.Response.Body); 1110httpContext.Response.Body.Seek(0, SeekOrigin.Begin); 1111using var responseJson = JsonDocument.Parse(httpContext.Response.Body); 1153httpContext.Response.Body.Seek(0, SeekOrigin.Begin); 1154using var responseJson = JsonDocument.Parse(httpContext.Response.Body); 1207httpContext.Response.Body.Seek(0, SeekOrigin.Begin); 1208using var responseJson = JsonDocument.Parse(httpContext.Response.Body); 1234httpContext.Response.Body.Seek(0, SeekOrigin.Begin); 1235using var responseJson = JsonDocument.Parse(httpContext.Response.Body); 1366httpContext.Response.Body.Seek(0, SeekOrigin.Begin); 1367var responseXml = XDocument.Load(httpContext.Response.Body); 1473httpContext.Response.Body.Seek(0, SeekOrigin.Begin); 1474using var responseJson = JsonDocument.Parse(httpContext.Response.Body); 1734httpContext.Response.Body.Seek(0, SeekOrigin.Begin); 1735using var responseJson = JsonDocument.Parse(httpContext.Response.Body);
Microsoft.AspNetCore.HostFiltering (1)
HostFilteringMiddleware.cs (1)
74return context.Response.Body.WriteAsync(DefaultResponse, 0, DefaultResponse.Length);
Microsoft.AspNetCore.Hosting (1)
src\Shared\RazorViews\BaseView.cs (1)
91await buffer.CopyToAsync(Response.Body);
Microsoft.AspNetCore.Hosting.Tests (2)
WebHostBuilderTests.cs (2)
1521httpContext.Response.Body.Seek(0, SeekOrigin.Begin); 1522var bodyText = new StreamReader(httpContext.Response.Body).ReadToEnd();
Microsoft.AspNetCore.Http.Abstractions.Tests (4)
HttpResponseWritingExtensionsTests.cs (4)
16Assert.Equal(11, context.Response.Body.Length); 26Assert.Equal(22, context.Response.Body.Length); 60context.Response.Body.Position = 0; 62var length = context.Response.Body.Read(actual);
Microsoft.AspNetCore.Http.Connections (5)
Internal\HttpConnectionContext.cs (1)
472await nonClonedContext.Response.Body.FlushAsync();
Internal\HttpConnectionDispatcher.cs (1)
398await writer.CopyToAsync(context.Response.Body);
Internal\Transports\LongPollingServerTransport.cs (1)
58await context.Response.Body.WriteAsync(buffer, _connection?.SendingToken ?? default);
Internal\Transports\ServerSentEventsServerTransport.cs (2)
48await context.Response.Body.FlushAsync(cancellationToken); 66await ServerSentEventsMessageFormatter.WriteMessageAsync(buffer, context.Response.Body, _connection?.SendingToken ?? default);
Microsoft.AspNetCore.Http.Connections.Tests (13)
HttpConnectionDispatcherTests.cs (13)
831Assert.Equal(Stream.Null, connectionHttpContext.Response.Body); 1781Assert.Equal(string.Empty, GetContentAsString(context1.Response.Body)); 1784Assert.Equal("Hello, World", GetContentAsString(context2.Response.Body)); 2981pollContext.Response.Body.Position = 0; 2982Assert.Equal(3, await pollContext.Response.Body.ReadAsync(memory).DefaultTimeout()); 2993pollContext.Response.Body.Position = 0; 2994Assert.Equal(3, await pollContext.Response.Body.ReadAsync(memory).DefaultTimeout()); 3038pollContext.Response.Body.Position = 0; 3039Assert.Equal(3, await pollContext.Response.Body.ReadAsync(memory).DefaultTimeout()); 3048pollContext.Response.Body.Position = 0; 3049Assert.Equal(3, await pollContext.Response.Body.ReadAsync(memory).DefaultTimeout()); 3170context.Response.Body.Position = 0; 3171Assert.Equal(1, await context.Response.Body.ReadAsync(memory).DefaultTimeout());
Microsoft.AspNetCore.Http.Extensions (3)
ResponseExtensions.cs (2)
29if (response.Body.CanSeek) 31response.Body.SetLength(0);
SendFileResponseExtensions.cs (1)
102await StreamCopyOperation.CopyToAsync(fileContent, response.Body, count, StreamCopyBufferSize, localCancel);
Microsoft.AspNetCore.Http.Extensions.Tests (5)
RequestDelegateGenerator\RequestDelegateCreationTestBase.cs (2)
235httpResponse.Body.Seek(0, SeekOrigin.Begin); 236var streamReader = new StreamReader(httpResponse.Body);
RequestDelegateGenerator\RequestDelegateCreationTests.Responses.cs (1)
315var deserializedResponseBody = JsonSerializer.Deserialize<Todo>(((MemoryStream)httpContext.Response.Body).ToArray(), new JsonSerializerOptions
ResponseExtensionTests.cs (2)
16context.Response.Body.Write(new byte[100], 0, 100); 22Assert.Equal(0, context.Response.Body.Length);
Microsoft.AspNetCore.Http.Microbenchmarks (2)
src\Http\Http.Extensions\test\RequestDelegateGenerator\RequestDelegateCreationTestBase.cs (2)
235httpResponse.Body.Seek(0, SeekOrigin.Begin); 236var streamReader = new StreamReader(httpResponse.Body);
Microsoft.AspNetCore.Http.Results (4)
PushStreamHttpResult.cs (1)
121_streamWriterCallback(httpContext.Response.Body);
src\Shared\ResultsHelpers\FileResultHelper.cs (2)
32var outputStream = context.Response.Body; 58var outputStream = context.Response.Body;
Utf8ContentHttpResult.cs (1)
68return httpContext.Response.Body.WriteAsync(ResponseContent).AsTask();
Microsoft.AspNetCore.Http.Results.Tests (46)
EmptyResultTests.cs (1)
18var memoryStream = httpContext.Response.Body as MemoryStream;
src\Shared\ResultsTests\FileContentResultTestBase.cs (16)
78httpResponse.Body.Seek(0, SeekOrigin.Begin); 79var streamReader = new StreamReader(httpResponse.Body); 116httpResponse.Body.Seek(0, SeekOrigin.Begin); 117var streamReader = new StreamReader(httpResponse.Body); 155httpResponse.Body.Seek(0, SeekOrigin.Begin); 156var streamReader = new StreamReader(httpResponse.Body); 189httpResponse.Body.Seek(0, SeekOrigin.Begin); 190var streamReader = new StreamReader(httpResponse.Body); 220httpResponse.Body.Seek(0, SeekOrigin.Begin); 221var streamReader = new StreamReader(httpResponse.Body); 251httpResponse.Body.Seek(0, SeekOrigin.Begin); 252var streamReader = new StreamReader(httpResponse.Body); 288httpResponse.Body.Seek(0, SeekOrigin.Begin); 289var streamReader = new StreamReader(httpResponse.Body); 322httpResponse.Body.Seek(0, SeekOrigin.Begin); 323var streamReader = new StreamReader(httpResponse.Body);
src\Shared\ResultsTests\FileStreamResultTestBase.cs (19)
56httpResponse.Body.Seek(0, SeekOrigin.Begin); 57var streamReader = new StreamReader(httpResponse.Body); 97httpResponse.Body.Seek(0, SeekOrigin.Begin); 98var streamReader = new StreamReader(httpResponse.Body); 138httpResponse.Body.Seek(0, SeekOrigin.Begin); 139var streamReader = new StreamReader(httpResponse.Body); 175httpResponse.Body.Seek(0, SeekOrigin.Begin); 176var streamReader = new StreamReader(httpResponse.Body); 208httpResponse.Body.Seek(0, SeekOrigin.Begin); 209var streamReader = new StreamReader(httpResponse.Body); 241httpResponse.Body.Seek(0, SeekOrigin.Begin); 242var streamReader = new StreamReader(httpResponse.Body); 280httpResponse.Body.Seek(0, SeekOrigin.Begin); 281var streamReader = new StreamReader(httpResponse.Body); 316httpResponse.Body.Seek(0, SeekOrigin.Begin); 317var streamReader = new StreamReader(httpResponse.Body); 357httpResponse.Body.Seek(0, SeekOrigin.Begin); 358var streamReader = new StreamReader(httpResponse.Body); 438Assert.Equal(0, httpContext.Response.Body.Length);
src\Shared\ResultsTests\PhysicalFileResultTestBase.cs (6)
199httpResponse.Body.Seek(0, SeekOrigin.Begin); 200var streamReader = new StreamReader(httpResponse.Body); 228httpResponse.Body.Seek(0, SeekOrigin.Begin); 229var streamReader = new StreamReader(httpResponse.Body); 255httpResponse.Body.Seek(0, SeekOrigin.Begin); 256var streamReader = new StreamReader(httpResponse.Body);
src\Shared\ResultsTests\VirtualFileResultTestBase.cs (4)
241httpResponse.Body.Seek(0, SeekOrigin.Begin); 242var streamReader = new StreamReader(httpResponse.Body); 459httpContext.Response.Body.Position = 0; 460var contents = await new StreamReader(httpContext.Response.Body).ReadToEndAsync();
Microsoft.AspNetCore.Http.Tests (3)
Internal\DefaultHttpResponseTests.cs (3)
85Assert.Same(originalStream, context.Response.Body); 90Assert.Same(replacementStream, context.Response.Body); 95Assert.Same(originalStream, context.Response.Body);
Microsoft.AspNetCore.HttpLogging (2)
HttpLoggingFields.cs (2)
97/// Response Headers are logged when the <see cref="HttpResponse.Body"/> is written to 132/// Flag for logging the HTTP Response <see cref="HttpResponse.Body"/>.
Microsoft.AspNetCore.Identity.InMemory.Test (1)
FunctionalTest.cs (1)
424await res.Body.WriteAsync(memory.ToArray(), 0, memory.ToArray().Length);
Microsoft.AspNetCore.Mvc.Abstractions (3)
Formatters\OutputFormatterWriteContext.cs (3)
36/// Write to <see cref="HttpResponse.Body"/> directly to write binary data to the response. 42/// <see cref="HttpResponse.Body"/> stream. Call this delegate to create a <see cref="TextWriter"/> 47/// <see cref="WriterFactory"/> delegate, and use <see cref="HttpResponse.Body"/> instead.
Microsoft.AspNetCore.Mvc.Core (8)
Formatters\StreamOutputFormatter.cs (1)
40await valueAsStream.CopyToAsync(response.Body);
Formatters\SystemTextJsonOutputFormatter.cs (1)
107var transcodingStream = Encoding.CreateTranscodingStream(httpContext.Response.Body, selectedEncoding, Encoding.UTF8, leaveOpen: true);
Infrastructure\ContentResultExecutor.cs (1)
62await using (var textWriter = _httpResponseStreamWriterFactory.CreateWriter(response.Body, resolvedContentTypeEncoding))
Infrastructure\IHttpResponseStreamWriterFactory.cs (2)
11/// Creates <see cref="TextWriter"/> instances for writing to <see cref="Http.HttpResponse.Body"/>. 18/// <param name="stream">The <see cref="Stream"/>, usually <see cref="Http.HttpResponse.Body"/>.</param>
Infrastructure\SystemTextJsonResultExecutor.cs (1)
77var transcodingStream = Encoding.CreateTranscodingStream(response.Body, resolvedContentTypeEncoding, Encoding.UTF8, leaveOpen: true);
src\Shared\ResultsHelpers\FileResultHelper.cs (2)
32var outputStream = context.Response.Body; 58var outputStream = context.Response.Body;
Microsoft.AspNetCore.Mvc.Core.Test (50)
FileResultHelperTest.cs (1)
96Assert.Equal(Stream.Null, httpContext.Response.Body);
Formatters\JsonOutputFormatterTestBase.cs (1)
153var body = outputFormatterContext.HttpContext.Response.Body;
Formatters\StringOutputFormatterTests.cs (1)
136response.SetupGet(r => r.Body).Returns(memoryStream);
Infrastructure\JsonResultExecutorTestBase.cs (2)
498context.Response.Body.Seek(0, SeekOrigin.Begin); 499return Assert.IsType<MemoryStream>(context.Response.Body).ToArray();
src\Shared\ResultsTests\FileContentResultTestBase.cs (16)
78httpResponse.Body.Seek(0, SeekOrigin.Begin); 79var streamReader = new StreamReader(httpResponse.Body); 116httpResponse.Body.Seek(0, SeekOrigin.Begin); 117var streamReader = new StreamReader(httpResponse.Body); 155httpResponse.Body.Seek(0, SeekOrigin.Begin); 156var streamReader = new StreamReader(httpResponse.Body); 189httpResponse.Body.Seek(0, SeekOrigin.Begin); 190var streamReader = new StreamReader(httpResponse.Body); 220httpResponse.Body.Seek(0, SeekOrigin.Begin); 221var streamReader = new StreamReader(httpResponse.Body); 251httpResponse.Body.Seek(0, SeekOrigin.Begin); 252var streamReader = new StreamReader(httpResponse.Body); 288httpResponse.Body.Seek(0, SeekOrigin.Begin); 289var streamReader = new StreamReader(httpResponse.Body); 322httpResponse.Body.Seek(0, SeekOrigin.Begin); 323var streamReader = new StreamReader(httpResponse.Body);
src\Shared\ResultsTests\FileStreamResultTestBase.cs (19)
56httpResponse.Body.Seek(0, SeekOrigin.Begin); 57var streamReader = new StreamReader(httpResponse.Body); 97httpResponse.Body.Seek(0, SeekOrigin.Begin); 98var streamReader = new StreamReader(httpResponse.Body); 138httpResponse.Body.Seek(0, SeekOrigin.Begin); 139var streamReader = new StreamReader(httpResponse.Body); 175httpResponse.Body.Seek(0, SeekOrigin.Begin); 176var streamReader = new StreamReader(httpResponse.Body); 208httpResponse.Body.Seek(0, SeekOrigin.Begin); 209var streamReader = new StreamReader(httpResponse.Body); 241httpResponse.Body.Seek(0, SeekOrigin.Begin); 242var streamReader = new StreamReader(httpResponse.Body); 280httpResponse.Body.Seek(0, SeekOrigin.Begin); 281var streamReader = new StreamReader(httpResponse.Body); 316httpResponse.Body.Seek(0, SeekOrigin.Begin); 317var streamReader = new StreamReader(httpResponse.Body); 357httpResponse.Body.Seek(0, SeekOrigin.Begin); 358var streamReader = new StreamReader(httpResponse.Body); 438Assert.Equal(0, httpContext.Response.Body.Length);
src\Shared\ResultsTests\PhysicalFileResultTestBase.cs (6)
199httpResponse.Body.Seek(0, SeekOrigin.Begin); 200var streamReader = new StreamReader(httpResponse.Body); 228httpResponse.Body.Seek(0, SeekOrigin.Begin); 229var streamReader = new StreamReader(httpResponse.Body); 255httpResponse.Body.Seek(0, SeekOrigin.Begin); 256var streamReader = new StreamReader(httpResponse.Body);
src\Shared\ResultsTests\VirtualFileResultTestBase.cs (4)
241httpResponse.Body.Seek(0, SeekOrigin.Begin); 242var streamReader = new StreamReader(httpResponse.Body); 459httpContext.Response.Body.Position = 0; 460var contents = await new StreamReader(httpContext.Response.Body).ReadToEndAsync();
Microsoft.AspNetCore.Mvc.Formatters.Xml (3)
XmlDataContractSerializerOutputFormatter.cs (2)
258var responseStream = response.Body; 277await fileBufferingWriteStream.DrainBufferAsync(response.Body);
XmlSerializerOutputFormatter.cs (1)
235var responseStream = response.Body;
Microsoft.AspNetCore.Mvc.Formatters.Xml.Test (23)
XmlDataContractSerializerOutputFormatterTest.cs (12)
108var body = outputFormatterContext.HttpContext.Response.Body; 172var body = formatterContext.HttpContext.Response.Body; 197var body = outputFormatterContext.HttpContext.Response.Body; 232var body = outputFormatterContext.HttpContext.Response.Body; 263var body = outputFormatterContext.HttpContext.Response.Body; 291var body = outputFormatterContext.HttpContext.Response.Body; 319var body = outputFormatterContext.HttpContext.Response.Body; 340var body = outputFormatterContext.HttpContext.Response.Body; 530var body = outputFormatterContext.HttpContext.Response.Body; 577var body = outputFormatterContext.HttpContext.Response.Body; 624var body = outputFormatterContext.HttpContext.Response.Body; 714var body = outputFormatterContext.HttpContext.Response.Body;
XmlSerializerOutputFormatterTest.cs (11)
62var body = outputFormatterContext.HttpContext.Response.Body; 98var body = outputFormatterContext.HttpContext.Response.Body; 118var body = outputFormatterContext.HttpContext.Response.Body; 174var body = formatterContext.HttpContext.Response.Body; 197var body = outputFormatterContext.HttpContext.Response.Body; 230var body = outputFormatterContext.HttpContext.Response.Body; 259var body = outputFormatterContext.HttpContext.Response.Body; 285var body = outputFormatterContext.HttpContext.Response.Body; 310var body = outputFormatterContext.HttpContext.Response.Body; 329Assert.NotNull(outputFormatterContext.HttpContext.Response.Body); 330Assert.True(outputFormatterContext.HttpContext.Response.Body.CanRead);
Microsoft.AspNetCore.Mvc.NewtonsoftJson (3)
NewtonsoftJsonOutputFormatter.cs (1)
144var responseStream = response.Body;
NewtonsoftJsonResultExecutor.cs (2)
94var responseStream = response.Body; 133await fileBufferingWriteStream.DrainBufferAsync(response.Body);
Microsoft.AspNetCore.Mvc.NewtonsoftJson.Test (12)
JsonResultTest.cs (2)
65context.Response.Body.Seek(0, SeekOrigin.Begin); 66return Assert.IsType<MemoryStream>(context.Response.Body).ToArray();
NewtonsoftJsonOutputFormatterTest.cs (7)
139var body = outputFormatterContext.HttpContext.Response.Body; 171var body = outputFormatterContext2.HttpContext.Response.Body; 214var body = context.HttpContext.Response.Body; 266var body = context.HttpContext.Response.Body; 302var body = context.HttpContext.Response.Body; 337var body = context.HttpContext.Response.Body; 424var body = context.HttpContext.Response.Body;
src\Mvc\Mvc.Core\test\Formatters\JsonOutputFormatterTestBase.cs (1)
153var body = outputFormatterContext.HttpContext.Response.Body;
src\Mvc\Mvc.Core\test\Infrastructure\JsonResultExecutorTestBase.cs (2)
498context.Response.Body.Seek(0, SeekOrigin.Begin); 499return Assert.IsType<MemoryStream>(context.Response.Body).ToArray();
Microsoft.AspNetCore.Mvc.Razor (2)
RazorPageBase.cs (2)
673/// on the response stream, writing out any buffered content to the <see cref="HttpResponse.Body"/>. 701await ViewContext.HttpContext.Response.Body.FlushAsync();
Microsoft.AspNetCore.Mvc.ViewFeatures (3)
ViewComponentResultExecutor.cs (2)
101await using var writer = _writerFactory.CreateWriter(response.Body, resolvedContentTypeEncoding); 132await bufferingStream.DrainBufferAsync(response.Body);
ViewExecutor.cs (1)
206await using (var writer = WriterFactory.CreateWriter(response.Body, resolvedContentTypeEncoding))
Microsoft.AspNetCore.Mvc.ViewFeatures.Test (2)
ViewComponentResultTest.cs (2)
724response.Body.Seek(0, SeekOrigin.Begin); 726using (var reader = new StreamReader(response.Body))
Microsoft.AspNetCore.OutputCaching.Tests (1)
TestUtils.cs (1)
283response.Body.Write(data, 0, data.Length);
Microsoft.AspNetCore.Owin.Tests (1)
OwinEnvironmentTests.cs (1)
93Assert.Same(Stream.Null, context.Response.Body);
Microsoft.AspNetCore.ResponseCaching (1)
ResponseCachingMiddleware.cs (1)
404context.OriginalResponseStream = context.HttpContext.Response.Body;
Microsoft.AspNetCore.ResponseCaching.Tests (1)
TestUtils.cs (1)
269response.Body.Write(data, 0, data.Length);
Microsoft.AspNetCore.ResponseCompression.Tests (12)
ResponseCompressionMiddlewareTest.cs (12)
640context.Response.Body.Flush(); 686await context.Response.Body.FlushAsync(); 737context.Response.Body.Write(new byte[10], 0, 10); 738context.Response.Body.Flush(); 740context.Response.Body.Write(new byte[90], 0, 90); 791await context.Response.Body.FlushAsync(); 860context.Response.Body.Write(new byte[1], 0, 1); 861context.Response.Body.Flush(); 925await context.Response.Body.FlushAsync(); 989await context.Response.Body.FlushAsync(); 1191context.Response.Body = new NoSyncWrapperStream(context.Response.Body); 1200await context.Response.Body.FlushAsync();
Microsoft.AspNetCore.Rewrite (1)
UrlActions\CustomResponseAction.cs (1)
42response.Body.Write(content, 0, content.Length);
Microsoft.AspNetCore.Routing.Tests (4)
Builder\RouteHandlerEndpointRouteBuilderExtensionsTest.cs (4)
905httpResponse.Body.Seek(0, SeekOrigin.Begin); 906var streamReader = new StreamReader(httpResponse.Body); 981httpResponse.Body.Seek(0, SeekOrigin.Begin); 982var streamReader = new StreamReader(httpResponse.Body);
Microsoft.AspNetCore.Server.HttpSys.FunctionalTests (76)
Http2Tests.cs (5)
172return httpContext.Request.Body.CopyToAsync(httpContext.Response.Body); 237return httpContext.Request.Body.CopyToAsync(httpContext.Response.Body); 553await httpContext.Response.Body.FlushAsync(); 585await httpContext.Response.Body.FlushAsync(); 706await httpContext.Response.Body.FlushAsync();
Http3Tests.cs (2)
191await httpContext.Response.Body.FlushAsync(); 221await httpContext.Response.Body.FlushAsync();
HttpsTests.cs (2)
44return httpContext.Response.Body.WriteAsync(body, 0, body.Length); 61await httpContext.Response.Body.WriteAsync(body, 0, body.Length);
OpaqueUpgradeTests.cs (1)
84await httpContext.Response.Body.FlushAsync();
RequestBodyLimitTests.cs (10)
33httpContext.Response.Body.Write(input, 0, read); 56await httpContext.Response.Body.WriteAsync(input, 0, read); 77httpContext.Response.Body.EndWrite(httpContext.Response.Body.BeginWrite(input, 0, read, null, null)); 100httpContext.Response.Body.Write(input, 0, read); 123await httpContext.Response.Body.WriteAsync(input, 0, read); 144httpContext.Response.Body.EndWrite(httpContext.Response.Body.BeginWrite(input, 0, read, null, null)); 373await httpContext.Response.Body.WriteAsync(input, 0, read); 397await httpContext.Response.Body.WriteAsync(input, 0, read);
RequestBodyTests.cs (8)
34httpContext.Response.Body.Write(input, 0, read); 56httpContext.Response.Body.Write(input, 0, read); 75await httpContext.Response.Body.WriteAsync(input, 0, read); 95await httpContext.Response.Body.WriteAsync(input, 0, read); 112httpContext.Response.Body.EndWrite(httpContext.Response.Body.BeginWrite(input, 0, read, null, null)); 197await httpContext.Response.Body.WriteAsync(input, 0, 10); 231await httpContext.Response.Body.WriteAsync(input, 0, read);
RequestTests.cs (5)
59httpContext.Response.Body.Write(body, 0, body.Length); 123httpContext.Response.Body.Write(body, 0, body.Length); 186httpContext.Response.Body.Write(body, 0, body.Length); 230httpContext.Response.Body.Write(body, 0, body.Length); 327httpContext.Response.Body.Write(body, 0, body.Length);
ResponseBodyTests.cs (19)
115httpContext.Response.Body.Write(new byte[10], 0, 10); 116return httpContext.Response.Body.WriteAsync(new byte[10], 0, 10); 146httpContext.Response.Body.Write(new byte[WriteSize], 0, WriteSize); 148await httpContext.Response.Body.WriteAsync(new byte[WriteSize], 0, WriteSize); 171httpContext.Response.Body.Write(new byte[10], 0, 10); 172await httpContext.Response.Body.WriteAsync(new byte[10], 0, 10); 173await httpContext.Response.Body.FlushAsync(); 193Stream stream = httpContext.Response.Body; 216Stream stream = httpContext.Response.Body; 254return httpContext.Response.Body.WriteAsync(new byte[5], 0, 5); 269await httpContext.Response.Body.WriteAsync(new byte[5], 0, 5); 271httpContext.Response.Body.WriteAsync(new byte[6], 0, 6)); 290httpContext.Response.Body.Write(new byte[10], 0, 10); 291httpContext.Response.Body.Write(new byte[9], 0, 9); 329httpContext.Response.Body.Write(new byte[10], 0, 10); 357httpContext.Response.Body.EndWrite(httpContext.Response.Body.BeginWrite(new byte[10], 0, 10, null, null)); 385return httpContext.Response.Body.WriteAsync(new byte[10], 0, 10); 413var body = httpContext.Response.Body;
ResponseCachingTests.cs (18)
54return httpContext.Response.Body.WriteAsync(new byte[10], 0, 10); 74return httpContext.Response.Body.WriteAsync(new byte[10], 0, 10); 95return httpContext.Response.Body.WriteAsync(new byte[10], 0, 10); 116return httpContext.Response.Body.WriteAsync(new byte[10], 0, 10); 141return httpContext.Response.Body.WriteAsync(new byte[10], 0, 10); 161return httpContext.Response.Body.WriteAsync(new byte[10], 0, 10); 181return httpContext.Response.Body.WriteAsync(new byte[10], 0, 10); 201return httpContext.Response.Body.WriteAsync(new byte[10], 0, 10); 221return httpContext.Response.Body.WriteAsync(new byte[10], 0, 10); 242return httpContext.Response.Body.WriteAsync(new byte[10], 0, 10); 266return httpContext.Response.Body.WriteAsync(new byte[10], 0, 10); 289return httpContext.Response.Body.WriteAsync(new byte[10], 0, 10); 309return httpContext.Response.Body.WriteAsync(new byte[10], 0, 10); 330return httpContext.Response.Body.WriteAsync(new byte[10], 0, 10); 350httpContext.Response.Body.FlushAsync(); 351return httpContext.Response.Body.WriteAsync(new byte[10], 0, 10); 371await httpContext.Response.Body.WriteAsync(new byte[10], 0, 10); 434return httpContext.Response.Body.WriteAsync(new byte[10], 0, 10);
ResponseHeaderTests.cs (4)
146return httpContext.Response.Body.FlushAsync(); // Http.Sys adds the Content-Length: header for us if we don't flush 194return response.Body.WriteAsync(responseBytes, 0, responseBytes.Length); 224var body = response.Body; 255var body = response.Body;
ResponseSendFileTests.cs (1)
317await httpContext.Response.Body.WriteAsync(new byte[10], 0, 10, CancellationToken.None);
ResponseTests.cs (1)
205Assert.Throws<InvalidTimeZoneException>(() => httpContext.Response.Body.Write(new byte[10], 0, 10));
Microsoft.AspNetCore.Server.IIS (1)
src\Shared\RazorViews\BaseView.cs (1)
91await buffer.CopyToAsync(Response.Body);
Microsoft.AspNetCore.Server.Kestrel.Core.Tests (3)
Http1\Http1ConnectionTests.cs (1)
958await context.Response.Body.WriteAsync(buffer, 0, 10);
src\Servers\Kestrel\shared\test\TestApp.cs (2)
23await response.Body.WriteAsync(buffer, 0, buffer.Length); 36await response.Body.WriteAsync(bytes, 0, bytes.Length);
Microsoft.AspNetCore.Server.Kestrel.Microbenchmarks (2)
InMemoryTransportBenchmark.cs (1)
265return response.Body.WriteAsync(_helloWorldPayload, 0, payloadLength);
NamedPipesTransportBenchmark.cs (1)
163return response.Body.WriteAsync(_helloWorldPayload, 0, payloadLength);
Microsoft.AspNetCore.SpaProxy (1)
SpaProxyMiddleware.cs (1)
62await using var writer = new StreamWriter(context.Response.Body, Encoding.UTF8);
Microsoft.AspNetCore.SpaServices.Extensions (1)
Proxying\SpaProxy.cs (1)
188await responseStream.CopyToAsync(context.Response.Body, StreamCopyBufferSize, cancellationToken);
Microsoft.AspNetCore.StaticAssets (1)
Development\StaticAssetDevelopmentRuntimeHandler.cs (1)
123return stream.CopyToAsync(_context.Response.Body, cancellationToken);
Microsoft.AspNetCore.StaticFiles (1)
HtmlDirectoryFormatter.cs (1)
206return context.Response.Body.WriteAsync(bytes, 0, bytes.Length);
Microsoft.AspNetCore.TestHost (2)
ClientHandler.cs (1)
217response.Content = new StreamContent(httpContext.Response.Body);
WebSocketClient.cs (1)
146await _httpContext.Response.Body.FlushAsync(_httpContext.RequestAborted); // Send headers to the client
Microsoft.AspNetCore.TestHost.Tests (35)
ClientHandlerTests.cs (6)
59Assert.NotNull(context.Response.Body); 207await context.Response.Body.FlushAsync(); 213await context.Response.Body.FlushAsync(); 428await context.Response.Body.FlushAsync(); 447await context.Response.Body.FlushAsync(); 469await context.Response.Body.FlushAsync();
HttpContextBuilderTests.cs (13)
42Assert.NotNull(context.Response.Body); 128c.Response.Body.Write(bytes, 0, bytes.Length); 131c.Response.Body.Write(bytes, 0, bytes.Length); 138var reader = new StreamReader(context.Response.Body); 162var reader = new StreamReader(context.Response.Body); 177await c.Response.Body.FlushAsync(); 187Assert.Equal("BodyFinished", new StreamReader(context.Response.Body).ReadToEnd()); 199await c.Response.Body.FlushAsync(); 208var responseStream = context.Response.Body; 248await c.Response.Body.FlushAsync(); 257var responseStream = context.Response.Body; 298Assert.Equal(11, context.Response.Body.Read(new byte[100], 0, 100)); 300var ex = Assert.Throws<IOException>(() => context.Response.Body.Read(new byte[100], 0, 100));
RequestLifetimeTests.cs (1)
56await httpContext.Response.Body.FlushAsync();
ResponseBodyTests.cs (8)
56httpContext.Response.Body.Write(contentBytes, 0, contentBytes.Length); 72httpContext.Response.Body.Write(contentBytes, 0, contentBytes.Length); 91await httpContext.Response.Body.WriteAsync(contentBytes, 0, contentBytes.Length); 92httpContext.Response.Body.Flush(); 110await httpContext.Response.Body.WriteAsync(contentBytes, 0, contentBytes.Length); 111httpContext.Response.Body.Flush(); 131await httpContext.Response.Body.WriteAsync(contentBytes); 133await httpContext.Response.Body.WriteAsync(contentBytes);
ResponseResetTests.cs (1)
113await httpContext.Response.Body.FlushAsync();
TestClientTests.cs (4)
140await ctx.Response.Body.WriteAsync(data, 0, 1024); 144await ctx.Response.Body.WriteAsync(data, 1024, 1024); 414await ctx.Response.Body.FlushAsync(); 833await ctx.Response.Body.FlushAsync();
TestServerTests.cs (2)
649context.Response.Body.Dispose(); 667context.Response.Body.Dispose();
ResponseCompressionSample (1)
Startup.cs (1)
53await context.Response.Body.FlushAsync();
RoutingSandbox (3)
HelloExtension\HelloMiddleware.cs (1)
37return response.Body.WriteAsync(_helloPayload, 0, payloadLength);
UseEndpointRoutingStartup.cs (2)
62return response.Body.WriteAsync(_plainTextPayload, 0, payloadLength); 68using (var writer = new StreamWriter(httpContext.Response.Body, Encoding.UTF8, 1024, leaveOpen: true))
RoutingWebSite (2)
HelloExtension\HelloMiddleware.cs (1)
37return response.Body.WriteAsync(_helloPayload, 0, payloadLength);
UseEndpointRoutingStartup.cs (1)
64return response.Body.WriteAsync(_plainTextPayload, 0, payloadLength);
ServerComparison.TestSites (2)
StartupResponses.cs (2)
30await context.Response.Body.FlushAsync(); // Bypass IIS write-behind buffering 39await context.Response.Body.FlushAsync(); // Bypass IIS write-behind buffering
SignalR.Client.FunctionalTestApp (1)
Startup.cs (1)
264using (var textWriter = new StreamWriter(context.Response.Body))
Sockets.FunctionalTests (4)
src\Servers\Kestrel\shared\test\TestApp.cs (2)
23await response.Body.WriteAsync(buffer, 0, buffer.Length); 36await response.Body.WriteAsync(bytes, 0, bytes.Length);
src\Servers\Kestrel\test\FunctionalTests\ResponseTests.cs (2)
372await context.Response.Body.WriteAsync(scratchBuffer, 0, scratchBuffer.Length); 786await context.Request.Body.CopyToAsync(context.Response.Body);