1 override of ContentLength
Microsoft.AspNetCore.Http (1)
Internal\DefaultHttpResponse.cs (1)
87public override long? ContentLength
200 writes to ContentLength
Benchmarks (2)
StartupUsingEndpointRouting.cs (1)
33response.ContentLength = payloadLength;
StartupUsingRouter.cs (1)
27response.ContentLength = payloadLength;
IIS.Microbenchmarks (1)
PlaintextBenchmark.cs (1)
69response.ContentLength = payloadLength;
InMemory.FunctionalTests (83)
Http2\Http2ConnectionTests.cs (1)
2369c.Response.ContentLength = 0;
Http2\Http2StreamTests.cs (14)
1335context.Response.ContentLength = 11; 1373context.Response.ContentLength = 11; 1412context.Response.ContentLength = 11; 1480context.Response.ContentLength = 0; 1678context.Response.ContentLength = 0; 1758context.Response.ContentLength = 11; 1826context.Response.ContentLength = 11; 4438response.ContentLength = 12; 4489response.ContentLength = 12; 4534httpContext.Response.ContentLength = 12; 4575response.ContentLength = 54; 4864context.Response.ContentLength = 25; 5308context.Response.ContentLength = 25; 5379context.Response.ContentLength = 25;
Http2\Http2WebSocketTests.cs (1)
532context.Response.ContentLength = 2;
Http3\Http3StreamTests.cs (3)
1239context.Response.ContentLength = 25; 1597context.Response.ContentLength = 25; 1655context.Response.ContentLength = 25;
HttpsConnectionMiddlewareTests.cs (1)
1085context.Response.ContentLength = 11;
LoggingConnectionMiddlewareTests.cs (1)
22context.Response.ContentLength = 12;
MaxRequestBodySizeTests.cs (1)
225context.Response.ContentLength = 1;
RequestBodyTimeoutTests.cs (1)
185context.Response.ContentLength = response.Length;
RequestTests.cs (12)
139context.Response.ContentLength = 12; 144context.Response.ContentLength = 14; 337context.Response.ContentLength = 1; 374context.Response.ContentLength = 1; 408context.Response.ContentLength = 1; 443context.Response.ContentLength = 1; 484context.Response.ContentLength = 1; 527context.Response.ContentLength = 1; 595context.Response.ContentLength = identifierLength; 1418context.Response.ContentLength = request.Length; 1712context.Response.ContentLength = 6; 1755context.Response.ContentLength = 5;
ResponseHeaderTests.cs (4)
28context.Response.ContentLength = 11; 59context.Response.ContentLength = 11; 92context.Response.ContentLength = 11; 121context.Response.ContentLength = 11;
ResponseTests.cs (44)
959httpContext.Response.ContentLength = 11; 1000httpContext.Response.ContentLength = 11; 1040httpContext.Response.ContentLength = 5; 1075httpContext.Response.ContentLength = 5; 1117httpContext.Response.ContentLength = 13; 1171httpContext.Response.ContentLength = 13; 1225httpContext.Response.ContentLength = 12; 1267httpContext.Response.ContentLength = 5; 1308httpContext.Response.ContentLength = 0; 1347httpContext.Response.ContentLength = 13; 1383httpContext.Response.ContentLength = 11; 1412httpContext.Response.ContentLength = 42; 1440httpContext.Response.ContentLength = 12; 1473httpContext.Response.ContentLength = 12; 1504httpContext.Response.ContentLength = 12; 1547httpContext.Response.ContentLength = ex.Message.Length; 1716httpContext.Response.ContentLength = null; 1721httpContext.Response.ContentLength = response.Length - 1; 1758httpContext.Response.ContentLength = null; 1763httpContext.Response.ContentLength = response.Length - 1; 1800httpContext.Response.ContentLength = null; 1805httpContext.Response.ContentLength = response.Length - 1; 1845httpContext.Response.ContentLength = null; 1850httpContext.Response.ContentLength = response.Length - 1; 1888httpContext.Response.ContentLength = null; 1893httpContext.Response.ContentLength = response.Length - 1; 1928httpContext.Response.ContentLength = null; 1933httpContext.Response.ContentLength = response.Length - 1; 2963httpContext.Response.ContentLength = 0; 3111httpContext.Response.ContentLength = 11; 3209httpContext.Response.ContentLength = expectedLength; 3255httpContext.Response.ContentLength = expectedLength; 3335context.Response.ContentLength = response.Length; 3386context.Response.ContentLength = response.Length; 3421context.Response.ContentLength = 6; 3451context.Response.ContentLength = 6; 3482context.Response.ContentLength = 6; 3517context.Response.ContentLength = 6; 3550response.ContentLength = 42; 3675response.ContentLength = 12; 3713response.ContentLength = 12; 3749httpContext.Response.ContentLength = 12; 3776response.ContentLength = 54; 4012httpContext.Response.ContentLength = 1;
InProcessWebSite (1)
src\Servers\IIS\IIS\test\testassets\InProcessWebSite\Startup.cs (1)
614ctx.Response.ContentLength = 9;
Kestrel.SampleApp (1)
Startup.cs (1)
61context.Response.ContentLength = response.Length;
LargeResponseApp (1)
Startup.cs (1)
31context.Response.ContentLength = _chunkSize * numChunks;
Microsoft.AspNetCore.Authentication.OpenIdConnect (2)
OpenIdConnectHandler.cs (2)
290Response.ContentLength = buffer.Length; 538Response.ContentLength = buffer.Length;
Microsoft.AspNetCore.Components.Endpoints (1)
Builder\ResourceCollectionUrlEndpoint.cs (1)
237context.Response.ContentLength = contents.Length;
Microsoft.AspNetCore.Diagnostics (1)
DeveloperExceptionPage\Views\CompilationErrorPage.Designer.cs (1)
59Response.ContentLength = null; // Clear any prior Content-Length
Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore (1)
Views\DatabaseErrorPage.Designer.cs (1)
45Response.ContentLength = null; // Clear any prior Content-Length
Microsoft.AspNetCore.HostFiltering (1)
HostFilteringMiddleware.cs (1)
72context.Response.ContentLength = DefaultResponse.Length;
Microsoft.AspNetCore.Http.Connections (4)
Internal\HttpConnectionContext.cs (1)
465nonClonedContext.Response.ContentLength = 0;
Internal\HttpConnectionDispatcher.cs (1)
397context.Response.ContentLength = writer.Length;
Internal\Transports\LongPollingServerTransport.cs (2)
54context.Response.ContentLength = buffer.Length; 86context.Response.ContentLength = 0;
Microsoft.AspNetCore.Http.Results (5)
HttpResultsHelper.cs (1)
84response.ContentLength = resolvedContentTypeEncoding.GetByteCount(content);
src\Shared\ResultsHelpers\FileResultHelper.cs (3)
136response.ContentLength = fileLength.Value; 317response.ContentLength = 0; 339response.ContentLength = length;
Utf8ContentHttpResult.cs (1)
67httpContext.Response.ContentLength = ResponseContent.Length;
Microsoft.AspNetCore.Mvc.Core (4)
Infrastructure\ContentResultExecutor.cs (1)
60response.ContentLength = resolvedContentTypeEncoding.GetByteCount(result.Content);
src\Shared\ResultsHelpers\FileResultHelper.cs (3)
136response.ContentLength = fileLength.Value; 317response.ContentLength = 0; 339response.ContentLength = length;
Microsoft.AspNetCore.Mvc.Core.Test (1)
Formatters\StringOutputFormatterTests.cs (1)
152response.VerifySet(r => r.ContentLength = It.IsAny<long?>(), Times.Never());
Microsoft.AspNetCore.Mvc.Formatters.Xml (2)
XmlDataContractSerializerOutputFormatter.cs (1)
276response.ContentLength = fileBufferingWriteStream.Length;
XmlSerializerOutputFormatter.cs (1)
253response.ContentLength = fileBufferingWriteStream.Length;
Microsoft.AspNetCore.Mvc.NewtonsoftJson (1)
NewtonsoftJsonOutputFormatter.cs (1)
180response.ContentLength = fileBufferingWriteStream.Length;
Microsoft.AspNetCore.OutputCaching.Tests (4)
OutputCacheMiddlewareTests.cs (4)
611context.HttpContext.Response.ContentLength = 20; 639context.HttpContext.Response.ContentLength = 9; 668context.HttpContext.Response.ContentLength = 10; 972context.HttpContext.Response.ContentLength = 5;
Microsoft.AspNetCore.ResponseCompression.Tests (3)
ResponseCompressionMiddlewareTest.cs (3)
1049context.Response.ContentLength = 1024; 1099context.Response.ContentLength = 1024; 1263context.Response.ContentLength = uncompressedBodyLength;
Microsoft.AspNetCore.Rewrite (1)
UrlActions\CustomResponseAction.cs (1)
40response.ContentLength = content.Length;
Microsoft.AspNetCore.Server.HttpSys.FunctionalTests (50)
HttpsTests.cs (2)
43httpContext.Response.ContentLength = body.Length; 60httpContext.Response.ContentLength = body.Length;
RequestBodyLimitTests.cs (8)
32httpContext.Response.ContentLength = read; 55httpContext.Response.ContentLength = read; 76httpContext.Response.ContentLength = read; 99httpContext.Response.ContentLength = read; 122httpContext.Response.ContentLength = read; 143httpContext.Response.ContentLength = read; 372httpContext.Response.ContentLength = read; 396httpContext.Response.ContentLength = read;
RequestBodyTests.cs (7)
33httpContext.Response.ContentLength = read; 55httpContext.Response.ContentLength = read; 74httpContext.Response.ContentLength = read; 94httpContext.Response.ContentLength = read; 111httpContext.Response.ContentLength = read; 196httpContext.Response.ContentLength = 10; 230httpContext.Response.ContentLength = read;
ResponseBodyTests.cs (1)
411httpContext.Response.ContentLength = data.Length;
ResponseCachingTests.cs (18)
53httpContext.Response.ContentLength = 10; 73httpContext.Response.ContentLength = 10; 94httpContext.Response.ContentLength = 10; 115httpContext.Response.ContentLength = 10; 140httpContext.Response.ContentLength = 10; 160httpContext.Response.ContentLength = 10; 180httpContext.Response.ContentLength = 10; 200httpContext.Response.ContentLength = 10; 220httpContext.Response.ContentLength = 10; 241httpContext.Response.ContentLength = 10; 265httpContext.Response.ContentLength = 10; 288httpContext.Response.ContentLength = 10; 308httpContext.Response.ContentLength = 10; 329httpContext.Response.ContentLength = 10; 349httpContext.Response.ContentLength = 10; 370httpContext.Response.ContentLength = 10; 411httpContext.Response.ContentLength = _fileLength; 433httpContext.Response.ContentLength = 10;
ResponseTrailersTests.cs (4)
124httpContext.Response.ContentLength = body.Length; 154httpContext.Response.ContentLength = body.Length * 2; 179httpContext.Response.ContentLength = body.Length; 205httpContext.Response.ContentLength = body.Length;
ServerTests.cs (10)
119httpContext.Response.ContentLength = 11; 135httpContext.Response.ContentLength = 11; 152httpContext.Response.ContentLength = 11; 174httpContext.Response.ContentLength = 11; 195httpContext.Response.ContentLength = 11; 424httpContext.Response.ContentLength = 11; 458httpContext.Response.ContentLength = 11; 495httpContext.Response.ContentLength = 11; 532httpContext.Response.ContentLength = 11; 571httpContext.Response.ContentLength = 11;
Microsoft.AspNetCore.Server.Kestrel.Microbenchmarks (10)
HeaderCollectionBenchmark.cs (4)
99_response.ContentLength = 0; 128_response.ContentLength = 13; 150_response.ContentLength = 421; 190_response.ContentLength = 13;
InMemoryTransportBenchmark.cs (1)
264response.ContentLength = payloadLength;
NamedPipesTransportBenchmark.cs (1)
162response.ContentLength = payloadLength;
ResponseHeaderCollectionBenchmark.cs (4)
77_response.ContentLength = 0; 101_response.ContentLength = 13; 118_response.ContentLength = 421; 153_response.ContentLength = 13;
Microsoft.AspNetCore.StaticAssets (2)
StaticAssetsInvoker.cs (2)
155context.Response.ContentLength = _length; 222requestContext.Response.ContentLength = length;
Microsoft.AspNetCore.StaticFiles (3)
HtmlDirectoryFormatter.cs (1)
205context.Response.ContentLength = bytes.Length;
StaticFileContext.cs (2)
269_response.ContentLength = _length; 381_response.ContentLength = length;
PlaintextApp (1)
Startup.cs (1)
30response.ContentLength = payload.Length;
RoutingSandbox (2)
HelloExtension\HelloMiddleware.cs (1)
36response.ContentLength = payloadLength;
UseEndpointRoutingStartup.cs (1)
61response.ContentLength = payloadLength;
RoutingWebSite (2)
HelloExtension\HelloMiddleware.cs (1)
36response.ContentLength = payloadLength;
UseEndpointRoutingStartup.cs (1)
63response.ContentLength = payloadLength;
ServerComparison.TestSites (4)
StartupResponseCompression.cs (3)
29context.Response.ContentLength = helloWorldBody.Length; 40context.Response.ContentLength = helloWorldBody.Length; 57context.Response.ContentLength = body.Length;
StartupResponses.cs (1)
19context.Response.ContentLength = 14;
Sockets.FunctionalTests (5)
src\Servers\Kestrel\test\FunctionalTests\ResponseTests.cs (5)
61context.Response.ContentLength = bytes.Length * 1024; 160httpContext.Response.ContentLength = 12; 527context.Response.ContentLength = responseSize; 667context.Response.ContentLength = chunks * chunkSize; 964context.Response.ContentLength = 0;
SystemdTestApp (1)
Startup.cs (1)
33context.Response.ContentLength = response.Length;
66 references to ContentLength
Microsoft.AspNetCore.Diagnostics (1)
StatusCodePage\StatusCodePagesMiddleware.cs (1)
70|| context.Response.ContentLength.HasValue
Microsoft.AspNetCore.Hosting (3)
Internal\HostingRequestFinishedLog.cs (3)
383 => new KeyValuePair<string, object?>(nameof(response.ContentLength), response.ContentLength), 66_cachedToString = $"Request finished {request.Protocol} {request.Method} {request.Scheme}://{request.Host.Value}{request.PathBase.Value}{request.Path.Value}{request.QueryString.Value} - {response.StatusCode.ToString(CultureInfo.InvariantCulture)} {ValueOrEmptyMarker(response.ContentLength)} {EscapedValueOrEmptyMarker(response.ContentType)} {Elapsed.TotalMilliseconds.ToString("0.0000", CultureInfo.InvariantCulture)}ms";
Microsoft.AspNetCore.Http.Connections.Tests (1)
LongPollingTests.cs (1)
56Assert.Equal(0, context.Response.ContentLength);
Microsoft.AspNetCore.Http.Results.Tests (26)
ContentResultTests.cs (1)
123Assert.Equal(expectedContentData.Length, httpContext.Response.ContentLength);
src\Shared\ResultsTests\FileContentResultTestBase.cs (5)
87Assert.Equal(contentLength, httpResponse.ContentLength); 126Assert.Equal(5, httpResponse.ContentLength); 260Assert.Equal(0, httpResponse.ContentLength); 292Assert.Null(httpResponse.ContentLength); 326Assert.Null(httpResponse.ContentLength);
src\Shared\ResultsTests\FileStreamResultTestBase.cs (6)
65Assert.Equal(contentLength, httpResponse.ContentLength); 106Assert.Equal(5, httpResponse.ContentLength); 250Assert.Equal(0, httpResponse.ContentLength); 284Assert.Null(httpResponse.ContentLength); 320Assert.Null(httpResponse.ContentLength); 366Assert.Equal(0, httpResponse.ContentLength);
src\Shared\ResultsTests\PhysicalFileResultTestBase.cs (6)
59Assert.Equal(contentLength, httpResponse.ContentLength); 91Assert.Equal(4, httpResponse.ContentLength); 207Assert.Equal(0, httpResponse.ContentLength); 232Assert.Null(httpResponse.ContentLength); 259Assert.Null(httpResponse.ContentLength); 319Assert.Equal(contentLength, httpResponse.ContentLength);
src\Shared\ResultsTests\VirtualFileResultTestBase.cs (6)
71Assert.Equal(contentLength, httpResponse.ContentLength); 108Assert.Equal(4, httpResponse.ContentLength); 249Assert.Equal(0, httpResponse.ContentLength); 278Assert.Null(httpResponse.ContentLength); 309Assert.Null(httpResponse.ContentLength); 354Assert.Equal(contentLength, httpResponse.ContentLength);
Utf8ContentResultTests.cs (2)
44Assert.Equal(data.Length, context.Response.ContentLength); 62Assert.Equal(data.Length, context.Response.ContentLength);
Microsoft.AspNetCore.Http.Tests (3)
Internal\DefaultHttpResponseTests.cs (3)
22Assert.Equal(value, response.ContentLength); 32Assert.Null(response.ContentLength); 46Assert.Null(response.ContentLength);
Microsoft.AspNetCore.Mvc.Core.Test (26)
ContentResultTest.cs (1)
140Assert.Equal(expectedContentData.Length, httpContext.Response.ContentLength);
Formatters\NoContentFormatterTests.cs (1)
150Assert.Null(context.HttpContext.Response.ContentLength);
Formatters\StringOutputFormatterTests.cs (1)
135response.SetupProperty(o => o.ContentLength);
src\Shared\ResultsTests\FileContentResultTestBase.cs (5)
87Assert.Equal(contentLength, httpResponse.ContentLength); 126Assert.Equal(5, httpResponse.ContentLength); 260Assert.Equal(0, httpResponse.ContentLength); 292Assert.Null(httpResponse.ContentLength); 326Assert.Null(httpResponse.ContentLength);
src\Shared\ResultsTests\FileStreamResultTestBase.cs (6)
65Assert.Equal(contentLength, httpResponse.ContentLength); 106Assert.Equal(5, httpResponse.ContentLength); 250Assert.Equal(0, httpResponse.ContentLength); 284Assert.Null(httpResponse.ContentLength); 320Assert.Null(httpResponse.ContentLength); 366Assert.Equal(0, httpResponse.ContentLength);
src\Shared\ResultsTests\PhysicalFileResultTestBase.cs (6)
59Assert.Equal(contentLength, httpResponse.ContentLength); 91Assert.Equal(4, httpResponse.ContentLength); 207Assert.Equal(0, httpResponse.ContentLength); 232Assert.Null(httpResponse.ContentLength); 259Assert.Null(httpResponse.ContentLength); 319Assert.Equal(contentLength, httpResponse.ContentLength);
src\Shared\ResultsTests\VirtualFileResultTestBase.cs (6)
71Assert.Equal(contentLength, httpResponse.ContentLength); 108Assert.Equal(4, httpResponse.ContentLength); 249Assert.Equal(0, httpResponse.ContentLength); 278Assert.Null(httpResponse.ContentLength); 309Assert.Null(httpResponse.ContentLength); 354Assert.Equal(contentLength, httpResponse.ContentLength);
Microsoft.AspNetCore.Mvc.Formatters.Xml.Test (1)
XmlSerializerOutputFormatterTest.cs (1)
414Assert.NotNull(outputFormatterContext.HttpContext.Response.ContentLength);
Microsoft.AspNetCore.Mvc.NewtonsoftJson.Test (1)
NewtonsoftJsonOutputFormatterTest.cs (1)
397Assert.NotNull(outputFormatterContext.HttpContext.Response.ContentLength);
Microsoft.AspNetCore.ResponseCaching (2)
ResponseCachingMiddleware.cs (2)
339var contentLength = context.HttpContext.Response.ContentLength; 347if (!response.ContentLength.HasValue && StringValues.IsNullOrEmpty(response.Headers.TransferEncoding))
Microsoft.AspNetCore.Server.HttpSys.FunctionalTests (1)
ResponseCachingTests.cs (1)
373Assert.Null(httpContext.Response.ContentLength);
Microsoft.AspNetCore.Server.Kestrel.Microbenchmarks (1)
HeaderCollectionBenchmark.cs (1)
215length = _response.ContentLength;