1 override of BodyWriter
Microsoft.AspNetCore.Http (1)
383 references to BodyWriter
CustomAuthorizationFailureResponse (1)
InMemory.FunctionalTests (309)
ChunkedResponseTests.cs (71)
27await response.BodyWriter.WriteAsync(new Memory<byte>(Encoding.ASCII.GetBytes("Hello "), 0, 6));
28await response.BodyWriter.WriteAsync(new Memory<byte>(Encoding.ASCII.GetBytes("World!"), 0, 6));
91await response.BodyWriter.WriteAsync(new Memory<byte>(Encoding.ASCII.GetBytes("Hello "), 0, 6));
92await response.BodyWriter.WriteAsync(new Memory<byte>(Encoding.ASCII.GetBytes("World!"), 0, 6));
202var memory = httpContext.Response.BodyWriter.GetMemory(length);
205httpContext.Response.BodyWriter.Advance(length);
206await httpContext.Response.BodyWriter.FlushAsync();
244var memory = httpContext.Response.BodyWriter.GetMemory(100000);
246httpContext.Response.BodyWriter.Advance(partialLength);
247await httpContext.Response.BodyWriter.FlushAsync();
317await response.BodyWriter.WriteAsync(new Memory<byte>(Encoding.ASCII.GetBytes("Hello "), 0, 6));
318await response.BodyWriter.WriteAsync(new Memory<byte>(new byte[0], 0, 0));
319await response.BodyWriter.WriteAsync(new Memory<byte>(Encoding.ASCII.GetBytes("World!"), 0, 6));
397await response.BodyWriter.WriteAsync(new Memory<byte>(new byte[0], 0, 0));
427await response.BodyWriter.WriteAsync(new Memory<byte>(Encoding.ASCII.GetBytes("Hello World!"), 0, 12));
460await response.BodyWriter.WriteAsync(new Memory<byte>(new byte[0], 0, 0));
494await response.BodyWriter.WriteAsync(new Memory<byte>(Encoding.ASCII.GetBytes("Hello "), 0, 6));
499await response.BodyWriter.WriteAsync(new Memory<byte>(Encoding.ASCII.GetBytes("World!"), 0, 6));
540await response.BodyWriter.WriteAsync(new Memory<byte>(Encoding.ASCII.GetBytes("6\r\nHello \r\n"), 0, 11));
541await response.BodyWriter.WriteAsync(new Memory<byte>(Encoding.ASCII.GetBytes("6\r\nWorld!\r\n"), 0, 11));
542await response.BodyWriter.WriteAsync(new Memory<byte>(Encoding.ASCII.GetBytes("0\r\n\r\n"), 0, 5));
578var memory = response.BodyWriter.GetMemory();
581response.BodyWriter.Advance(6);
583memory = response.BodyWriter.GetMemory();
586response.BodyWriter.Advance(6);
588await response.BodyWriter.FlushAsync();
621var memory = response.BodyWriter.GetMemory();
624response.BodyWriter.Advance(6);
626memory = response.BodyWriter.GetMemory();
629response.BodyWriter.Advance(6);
631await response.BodyWriter.FlushAsync();
666var memory = response.BodyWriter.GetMemory(5000);
672response.BodyWriter.Advance(memory.Length);
674memory = response.BodyWriter.GetMemory();
677response.BodyWriter.Advance(6);
679await response.BodyWriter.FlushAsync();
720await response.BodyWriter.FlushAsync();
722var memory = response.BodyWriter.GetMemory(5000);
728response.BodyWriter.Advance(memory.Length);
730memory = response.BodyWriter.GetMemory();
733response.BodyWriter.Advance(6);
735await response.BodyWriter.FlushAsync();
778var memory = response.BodyWriter.GetMemory();
784response.BodyWriter.Advance(length);
786var secondMemory = response.BodyWriter.GetMemory(6);
790response.BodyWriter.Advance(6);
792await response.BodyWriter.FlushAsync();
833var memory = response.BodyWriter.GetMemory(4096);
836response.BodyWriter.Advance(6);
840response.BodyWriter.Advance(6);
877var span = response.BodyWriter.GetSpan(4096);
880response.BodyWriter.Advance(6);
884response.BodyWriter.Advance(6);
922var memory = response.BodyWriter.GetMemory(4096);
926response.BodyWriter.Advance(6);
961var memory = response.BodyWriter.GetMemory(4096);
964response.BodyWriter.Advance(6);
1003var memory = response.BodyWriter.GetMemory(0);
1008memory = response.BodyWriter.GetMemory(1000000);
1040var memory = response.BodyWriter.GetMemory(0);
1044memory = response.BodyWriter.GetMemory(1000000);
1076var memory = response.BodyWriter.GetMemory(4096);
1079response.BodyWriter.Advance(writeSize);
1080await response.BodyWriter.FlushAsync();
1115var memory = response.BodyWriter.GetMemory(4096);
1118response.BodyWriter.Advance(writeSize);
1119await response.BodyWriter.FlushAsync();
1150var memory = response.BodyWriter.GetMemory(4096);
1153response.BodyWriter.Advance(6);
1156response.BodyWriter.Advance(6);
1159await response.BodyWriter.WriteAsync(Encoding.ASCII.GetBytes("hello, world"));
ResponseTests.cs (92)
82await context.Response.BodyWriter.FlushAsync();
161var writeTask = context.Response.BodyWriter.WriteAsync(new Memory<byte>(data, 0, data.Length), cts.Token).AsTask().DefaultTimeout();
168writeTask = context.Response.BodyWriter.WriteAsync(new Memory<byte>(data, 0, data.Length), cts.Token).AsTask().DefaultTimeout();
223var result = await context.Response.BodyWriter.WriteAsync(payload);
248context.Response.BodyWriter.CancelPendingFlush();
250var cancelledResult = await context.Response.BodyWriter.WriteAsync(payload);
254var goodResult = await context.Response.BodyWriter.WriteAsync(secondPayload);
916await httpContext.Response.BodyWriter.FlushAsync();
960await httpContext.Response.BodyWriter.WriteAsync(new Memory<byte>(Encoding.ASCII.GetBytes("hello,"), 0, 6));
961await httpContext.Response.BodyWriter.WriteAsync(new Memory<byte>(Encoding.ASCII.GetBytes(" world"), 0, 6));
1041await httpContext.Response.BodyWriter.WriteAsync(new Memory<byte>(response, 0, response.Length));
1076await httpContext.Response.BodyWriter.WriteAsync(new Memory<byte>(response, 0, response.Length));
1174completeEx = Assert.Throws<InvalidOperationException>(() => httpContext.Response.BodyWriter.Complete());
1312await httpContext.Response.BodyWriter.FlushAsync();
1474await httpContext.Response.BodyWriter.WriteAsync(new Memory<byte>(Encoding.ASCII.GetBytes("hello, world"), 0, 12));
1724await httpContext.Response.BodyWriter.WriteAsync(new Memory<byte>(response, 0, response.Length));
1808await httpContext.Response.BodyWriter.WriteAsync(new Memory<byte>(response, 0, response.Length / 2));
1809await httpContext.Response.BodyWriter.WriteAsync(new Memory<byte>(response, response.Length / 2, response.Length - response.Length / 2));
1896return httpContext.Response.BodyWriter.WriteAsync(new Memory<byte>(response, 0, response.Length)).AsTask();
1936await httpContext.Response.BodyWriter.WriteAsync(new Memory<byte>(response, 0, response.Length / 2));
1937await httpContext.Response.BodyWriter.WriteAsync(new Memory<byte>(response, response.Length / 2, response.Length - response.Length / 2));
2493var writeException = await Assert.ThrowsAsync<ObjectDisposedException>(async () => await response.BodyWriter.FlushAsync());
2551await response.BodyWriter.WriteAsync(new Memory<byte>(Encoding.ASCII.GetBytes("Hello World"), 0, 11));
2597await response.BodyWriter.WriteAsync(new Memory<byte>(Encoding.ASCII.GetBytes("Hello World"), 0, 11));
2644await response.BodyWriter.WriteAsync(new Memory<byte>(Encoding.ASCII.GetBytes("Hello World"), 0, 11));
2690await response.BodyWriter.WriteAsync(new Memory<byte>(Encoding.ASCII.GetBytes("Hello World"), 0, 11));
2735await response.BodyWriter.WriteAsync(new Memory<byte>(Encoding.ASCII.GetBytes("Hello"), 0, 5));
2770await response.BodyWriter.WriteAsync(new Memory<byte>(Encoding.ASCII.GetBytes("Hello World"), 0, 11));
3257WriteStringWithoutFlushing(httpContext.Response.BodyWriter, expectedString);
3288await httpContext.Response.BodyWriter.FlushAsync();
3523return context.Response.BodyWriter.WriteAsync(new Memory<byte>(Encoding.ASCII.GetBytes("Hello!"), 0, 6)).AsTask();
3583Assert.Throws<ArgumentOutOfRangeException>(() => response.BodyWriter.Advance(-1));
3614Assert.Throws<ArgumentOutOfRangeException>(() => response.BodyWriter.Advance(-1));
3644Assert.Throws<InvalidOperationException>(() => response.BodyWriter.Advance(1));
3677var span = response.BodyWriter.GetSpan(4096);
3680response.BodyWriter.Advance(6);
3684response.BodyWriter.Advance(6);
3717var memory = response.BodyWriter.GetMemory(4096);
3720response.BodyWriter.Advance(6);
3724response.BodyWriter.Advance(6);
3778var memory = response.BodyWriter.GetMemory(4096);
3781response.BodyWriter.Advance(6);
3784response.BodyWriter.Advance(8);
3787await response.BodyWriter.WriteAsync(Encoding.ASCII.GetBytes("hello, world\r\n"));
3817httpContext.Response.BodyWriter.Complete();
3845httpContext.Response.BodyWriter.Complete();
3877await httpContext.Response.BodyWriter.CompleteAsync();
3914var memory = httpContext.Response.BodyWriter.GetMemory();
3916httpContext.Response.BodyWriter.Advance(1);
3917await httpContext.Response.BodyWriter.FlushAsync();
3960var memory = httpContext.Response.BodyWriter.GetMemory();
3962httpContext.Response.BodyWriter.Advance(1);
3963await httpContext.Response.BodyWriter.FlushAsync();
4013var memory = httpContext.Response.BodyWriter.GetMemory();
4015httpContext.Response.BodyWriter.Advance(1);
4016await httpContext.Response.BodyWriter.FlushAsync();
4020var memory = httpContext.Response.BodyWriter.GetMemory();
4022httpContext.Response.BodyWriter.Advance(1);
4023await httpContext.Response.BodyWriter.FlushAsync();
4073Assert.Throws<InvalidOperationException>(() => httpContext.Response.BodyWriter.Advance(1));
4077var memory = httpContext.Response.BodyWriter.GetMemory();
4116httpContext.Response.BodyWriter.Complete(expectedException);
4145httpContext.Response.BodyWriter.Complete();
4146var memory = httpContext.Response.BodyWriter.GetMemory(); // Shouldn't throw
4176httpContext.Response.BodyWriter.Complete();
4177var memory = httpContext.Response.BodyWriter.GetMemory(); // Shouldn't throw
4205var memory = httpContext.Response.BodyWriter.GetMemory();
4211memory = httpContext.Response.BodyWriter.GetMemory();
4240var memory = httpContext.Response.BodyWriter.GetMemory();
4244Assert.Throws<InvalidOperationException>(() => httpContext.Response.BodyWriter.Advance(1));
4274httpContext.Response.BodyWriter.Complete();
4276writeEx = Assert.Throws<InvalidOperationException>(() => httpContext.Response.BodyWriter.GetMemory());
4306var BodyWriter1 = httpContext.Response.BodyWriter;
4309var BodyWriter2 = httpContext.Response.BodyWriter;
4340await httpContext.Response.BodyWriter.WriteAsync(new byte[1]);
4579var memory = context.Response.BodyWriter.GetMemory();
4580context.Response.BodyWriter.Advance(memory.Length);
4582Assert.Equal(length, context.Response.BodyWriter.UnflushedBytes);
4584memory = context.Response.BodyWriter.GetMemory();
4585context.Response.BodyWriter.Advance(memory.Length);
4588Assert.Equal(length, context.Response.BodyWriter.UnflushedBytes);
4590await context.Response.BodyWriter.FlushAsync();
4592Assert.Equal(0, context.Response.BodyWriter.UnflushedBytes);
4631await context.Response.BodyWriter.FlushAsync();
4634var memory = context.Response.BodyWriter.GetMemory();
4635context.Response.BodyWriter.Advance(memory.Length);
4637Assert.Equal(length, context.Response.BodyWriter.UnflushedBytes);
4639memory = context.Response.BodyWriter.GetMemory();
4640context.Response.BodyWriter.Advance(memory.Length);
4644Assert.Equal(length + 7, context.Response.BodyWriter.UnflushedBytes);
4646await context.Response.BodyWriter.FlushAsync();
4648Assert.Equal(0, context.Response.BodyWriter.UnflushedBytes);
Interop.FunctionalTests (18)
JwtBearerSample (2)
Microsoft.AspNetCore.Grpc.JsonTranscoding (1)
Microsoft.AspNetCore.Http.Abstractions (3)
Microsoft.AspNetCore.Http.Extensions (10)
HttpResponseJsonExtensions.cs (10)
96return WriteAsJsonAsyncSlow(response.BodyWriter, value, options, response.HttpContext.RequestAborted);
99return JsonSerializer.SerializeAsync(response.BodyWriter, value, options, cancellationToken);
130return JsonSerializer.SerializeAsync(response.BodyWriter, value, jsonTypeInfo, cancellationToken);
137await JsonSerializer.SerializeAsync(response.BodyWriter, value, jsonTypeInfo, cancellationToken);
172return JsonSerializer.SerializeAsync(response.BodyWriter, value, jsonTypeInfo, cancellationToken);
179await JsonSerializer.SerializeAsync(response.BodyWriter, value, jsonTypeInfo, cancellationToken);
275return WriteAsJsonAsyncSlow(response.BodyWriter, value, type, options,
279return JsonSerializer.SerializeAsync(response.BodyWriter, value, type, options, cancellationToken);
326return WriteAsJsonAsyncSlow(response.BodyWriter, value, type, context, response.HttpContext.RequestAborted);
329return JsonSerializer.SerializeAsync(response.BodyWriter, value, type, context, cancellationToken);
Microsoft.AspNetCore.Http.Tests (1)
Microsoft.AspNetCore.Mvc.Core (2)
Microsoft.AspNetCore.Mvc.Formatters.Xml (1)
Microsoft.AspNetCore.Mvc.NewtonsoftJson (1)
Microsoft.AspNetCore.OpenApi (2)
Microsoft.AspNetCore.OutputCaching.Tests (2)
Microsoft.AspNetCore.ResponseCaching (1)
Microsoft.AspNetCore.ResponseCaching.Microbenchmarks (1)
Microsoft.AspNetCore.Server.HttpSys.FunctionalTests (2)
Microsoft.AspNetCore.Server.Kestrel.Core.Tests (6)
Microsoft.AspNetCore.TestHost.Tests (5)
PlaintextApp (1)
SignalRSamples (1)
Sockets.FunctionalTests (13)
src\Servers\Kestrel\test\FunctionalTests\ResponseTests.cs (7)
65await context.Response.BodyWriter.WriteAsync(new Memory<byte>(bytes, 0, bytes.Length));
309await context.Response.BodyWriter.WriteAsync(new Memory<byte>(scratchBuffer, 0, scratchBuffer.Length), context.RequestAborted);
535await context.Response.BodyWriter.WriteAsync(new Memory<byte>(chunkData, 0, chunkData.Length), context.RequestAborted);
673await context.Response.BodyWriter.WriteAsync(new Memory<byte>(chunkData, 0, chunkData.Length), context.RequestAborted);
888await context.Response.BodyWriter.WriteAsync(new Memory<byte>(chunkData, 0, chunkData.Length), context.RequestAborted);
966await context.Response.BodyWriter.FlushAsync();
1052await context.Response.BodyWriter.WriteAsync(new Memory<byte>(chunkData, 0, chunkData.Length), context.RequestAborted);