2 writes to Headers
Microsoft.Build.Tasks.UnitTests (2)
DownloadFile_Tests.cs (2)
96Headers = 327Headers =
698 references to Headers
Aspire.Dashboard.Tests (20)
Integration\OtlpHttpServiceTests.cs (16)
44content.Headers.TryAddWithoutValidation("content-type", OtlpHttpEndpointsBuilder.ProtobufContentType); 53Assert.Equal(OtlpHttpEndpointsBuilder.ProtobufContentType, responseMessage.Content.Headers.GetValues("content-type").Single()); 70content.Headers.TryAddWithoutValidation("content-type", OtlpHttpEndpointsBuilder.ProtobufContentType); 114content.Headers.TryAddWithoutValidation("content-type", OtlpHttpEndpointsBuilder.ProtobufContentType); 138content.Headers.TryAddWithoutValidation("content-type", OtlpHttpEndpointsBuilder.ProtobufContentType); 166content.Headers.TryAddWithoutValidation("content-type", OtlpHttpEndpointsBuilder.ProtobufContentType); 179Assert.Equal(OtlpHttpEndpointsBuilder.ProtobufContentType, responseMessage.Content.Headers.GetValues("content-type").Single()); 204content.Headers.TryAddWithoutValidation("content-type", OtlpHttpEndpointsBuilder.ProtobufContentType); 233content.Headers.TryAddWithoutValidation("content-type", contentType); 259content.Headers.TryAddWithoutValidation("content-type", OtlpHttpEndpointsBuilder.ProtobufContentType); 285content.Headers.TryAddWithoutValidation("content-type", OtlpHttpEndpointsBuilder.ProtobufContentType); 294Assert.Equal(OtlpHttpEndpointsBuilder.ProtobufContentType, responseMessage.Content.Headers.GetValues("content-type").Single()); 314content.Headers.TryAddWithoutValidation("content-type", OtlpHttpEndpointsBuilder.ProtobufContentType); 323Assert.Equal(OtlpHttpEndpointsBuilder.ProtobufContentType, responseMessage.Content.Headers.GetValues("content-type").Single()); 343content.Headers.TryAddWithoutValidation("content-type", OtlpHttpEndpointsBuilder.ProtobufContentType); 352Assert.Equal(OtlpHttpEndpointsBuilder.ProtobufContentType, responseMessage.Content.Headers.GetValues("content-type").Single());
Integration\ResponseCompressionTests.cs (2)
32Assert.DoesNotContain(response.Content.Headers, h => h.Key == "Content-Encoding"); 54Assert.Contains(response.Content.Headers, h => h.Key == "Content-Encoding" && h.Value.Contains("br"));
Integration\StartupTests.cs (2)
405content.Headers.TryAddWithoutValidation("content-type", OtlpHttpEndpointsBuilder.ProtobufContentType); 412Assert.Equal(OtlpHttpEndpointsBuilder.ProtobufContentType, responseMessage.Content.Headers.GetValues("content-type").Single());
AuthSamples.FunctionalTests (3)
HttpClientExtensions.cs (1)
56submision.Content.Headers.TryAddWithoutValidation(header.Key, header.Value);
TestAssert.cs (2)
76Assert.Equal("text/html", response.Content.Headers.ContentType.MediaType); 89MapHeaders(response.Content.Headers);
Binding.Http.IntegrationTests (4)
BasicHttpBindingTests.4.0.0.cs (4)
166foreach (var header in oldContent.Headers) 168if (!header.Key.Equals("Content-Length") && message.Content.Headers.Contains(header.Key)) 170message.Content.Headers.Remove(header.Key); 173message.Content.Headers.Add(header.Key, header.Value);
dotnet-svcutil-lib (25)
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\HttpRequestMessageExtensionMethods.cs (2)
84MergeWebHeaderCollectionWithHttpHeaders(headersToMerge, requestMessage.Headers, requestMessage.Content.Headers); 107headers = headers.Concat(httpRequest.Content.Headers);
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\HttpRequestMessageProperty.cs (5)
324long? contentLength = content.Headers.ContentLength; 340(!content.Headers.ContentLength.HasValue || 341content.Headers.ContentLength.Value > 0)) 344foreach (KeyValuePair<string, IEnumerable<string>> header in content.Headers) 346newContent.Headers.AddHeaderWithoutValidation(header);
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\HttpResponseMessageExtensionMethods.cs (2)
45HttpRequestMessageExtensionMethods.MergeWebHeaderCollectionWithHttpHeaders(headersToMerge, responseMessage.Headers, responseMessage.Content.Headers); 53headers = headers.Concat(httpResponse.Content.Headers);
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\HttpResponseMessageHelper.cs (7)
132var mediaValueContentType = content.Headers.ContentType; 134_contentLength = content.Headers.ContentLength.HasValue ? content.Headers.ContentLength.Value : -1; 175if (!content.Headers.ContentLength.HasValue) 297_contentLength = content.Headers.ContentLength.HasValue ? content.Headers.ContentLength.Value : -1; 341throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ProtocolException(string.Format(SRServiceModel.FramingContentTypeMismatch, _httpRequestMessage.Content.Headers.ContentType.ToString(), _httpRequestMessage.RequestUri)));
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\HttpResponseMessageProperty.cs (5)
348long? contentLength = content.Headers.ContentLength; 364(!content.Headers.ContentLength.HasValue || 365content.Headers.ContentLength.Value > 0)) 368foreach (KeyValuePair<string, IEnumerable<string>> header in content.Headers) 370newContent.Headers.AddHeaderWithoutValidation(header);
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\MessageContent.cs (4)
96var actionParams = (from p in Headers.ContentType.Parameters where p.Name == "action" select p).ToArray(); 113new ProtocolException(string.Format(SRServiceModel.HttpContentTypeFormatException, formatException.Message, Headers.ContentType.ToString()), formatException)); 120Headers.ContentType.Parameters.Add(new NameValueHeaderValue("action", action)); 132Headers.ContentType = contentTypeHeaderValue;
HttpStress (2)
Program.cs (2)
329if (m.Content.Headers.ContentLength != maxContentLength) 331throw new Exception($"Expected {maxContentLength}, got {m.Content.Headers.ContentLength}");
IIS.FunctionalTests (6)
Http2TrailersResetTests.cs (2)
118Assert.True(response.Content.Headers.TryGetValues(HeaderNames.ContentLength, out var contentLength), HeaderNames.ContentLength); 136Assert.True(response.Content.Headers.TryGetValues(HeaderNames.ContentLength, out var contentLength), HeaderNames.ContentLength);
src\Servers\IIS\IIS\test\Common.FunctionalTests\CompressionTests.cs (1)
144Assert.True(response.Content.Headers.TryGetValues("Content-Type", out var contentTypes));
src\Servers\IIS\IIS\test\Common.FunctionalTests\RequestResponseTests.cs (3)
132Assert.Equal("gzip", response.Content.Headers.ContentEncoding.Single()); 150Assert.Equal("gzip", response.Content.Headers.ContentEncoding.Single()); 533Assert.True(response.Content.Headers.TryGetValues(Net.Http.Headers.HeaderNames.ContentType, out headerValues));
IISExpress.FunctionalTests (4)
src\Servers\IIS\IIS\test\Common.FunctionalTests\CompressionTests.cs (1)
144Assert.True(response.Content.Headers.TryGetValues("Content-Type", out var contentTypes));
src\Servers\IIS\IIS\test\Common.FunctionalTests\RequestResponseTests.cs (3)
132Assert.Equal("gzip", response.Content.Headers.ContentEncoding.Single()); 150Assert.Equal("gzip", response.Content.Headers.ContentEncoding.Single()); 533Assert.True(response.Content.Headers.TryGetValues(Net.Http.Headers.HeaderNames.ContentType, out headerValues));
InMemory.FunctionalTests (2)
TestTransport\InMemoryHttpClientSlim.cs (2)
80await writer.WriteAsync($"Content-Type: {content.Headers.ContentType}\r\n").ConfigureAwait(false); 81await writer.WriteAsync($"Content-Length: {content.Headers.ContentLength}\r\n").ConfigureAwait(false);
Interop.FunctionalTests (1)
Http3\Http3RequestTests.cs (1)
372requestContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("text/plain");
Microsoft.AspNetCore.Authentication.OpenIdConnect (5)
OpenIdConnectHandler.cs (5)
611var contentType = parResponseMessage.Content.Headers.ContentType; 996var contentMediaType = responseMessage.Content.Headers.ContentType?.MediaType; 1005Logger.LogDebug($"Unexpected token response format. Status Code: {(int)responseMessage.StatusCode}. Content-Type {responseMessage.Content.Headers.ContentType}."); 1021throw new OpenIdConnectProtocolException($"Failed to parse token response body as JSON. Status Code: {(int)responseMessage.StatusCode}. Content-Type: {responseMessage.Content.Headers.ContentType}", ex); 1065var contentType = responseMessage.Content.Headers.ContentType;
Microsoft.AspNetCore.Authentication.Test (25)
CertificateTests.cs (14)
470response.Content.Headers.ContentType != null && 471response.Content.Headers.ContentType.MediaType == "text/xml") 601response.Content.Headers.ContentType != null && 602response.Content.Headers.ContentType.MediaType == "text/xml") 620response.Content.Headers.ContentType != null && 621response.Content.Headers.ContentType.MediaType == "text/xml") 671response.Content.Headers.ContentType != null && 672response.Content.Headers.ContentType.MediaType == "text/xml") 728response.Content.Headers.ContentType != null && 729response.Content.Headers.ContentType.MediaType == "text/xml") 747response.Content.Headers.ContentType != null && 748response.Content.Headers.ContentType.MediaType == "text/xml") 769response.Content.Headers.ContentType != null && 770response.Content.Headers.ContentType.MediaType == "text/xml")
CookieTests.cs (2)
1926transaction.Response.Content.Headers.ContentType != null && 1927transaction.Response.Content.Headers.ContentType.MediaType == "text/xml")
JwtBearerTests.cs (2)
1265transaction.Response.Content.Headers.ContentType != null && 1266transaction.Response.Content.Headers.ContentType.MediaType == "text/xml")
JwtBearerTests_Handler.cs (2)
1324transaction.Response.Content.Headers.ContentType != null && 1325transaction.Response.Content.Headers.ContentType.MediaType == "text/xml")
OpenIdConnect\OpenIdConnectChallengeTests.cs (1)
165Assert.Equal("text/html", transaction.Response.Content.Headers.ContentType.MediaType);
OpenIdConnect\TestServerExtensions.cs (2)
42transaction.Response.Content.Headers.ContentType != null && 43transaction.Response.Content.Headers.ContentType.MediaType == "text/xml")
TestExtensions.cs (2)
37transaction.Response.Content.Headers.ContentType != null && 38transaction.Response.Content.Headers.ContentType.MediaType == "text/xml")
Microsoft.AspNetCore.Authentication.Twitter (1)
TwitterHandler.cs (1)
358var contentTypeIsJson = string.Equals(response.Content.Headers.ContentType?.MediaType ?? "", "application/json", StringComparison.OrdinalIgnoreCase);
Microsoft.AspNetCore.CookiePolicy.Test (2)
TestExtensions.cs (2)
34transaction.Response.Content.Headers.ContentType != null && 35transaction.Response.Content.Headers.ContentType.MediaType == "text/xml")
Microsoft.AspNetCore.Diagnostics.HealthChecks.Tests (24)
HealthCheckEndpointRouteBuilderExtensionsTest.cs (2)
81Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 126Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString());
HealthCheckMiddlewareSampleTest.cs (4)
31Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 53Assert.Equal("application/json", response.Content.Headers.ContentType.ToString()); 76Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 98Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString());
HealthCheckMiddlewareTests.cs (18)
122Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 152Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 185Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 218Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 251Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 284Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 329Assert.Equal("application/json", response.Content.Headers.ContentType.ToString()); 434Assert.Equal(new string[] { "Thu, 01 Jan 1970 00:00:00 GMT" }, response.Content.Headers.GetValues(HeaderNames.Expires)); 469Assert.False(response.Content.Headers.Contains(HeaderNames.Expires)); 505Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 535Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 593Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 658Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 695Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 733Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 771Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 851Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 895Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString());
Microsoft.AspNetCore.Diagnostics.Tests (7)
DeveloperExceptionPageMiddlewareTest.cs (3)
261Assert.Equal("text/html", response.Content.Headers.ContentType.MediaType); 296Assert.Equal("text/plain", response.Content.Headers.ContentType.MediaType); 297Assert.Equal("utf-8", response.Content.Headers.ContentType.CharSet);
ExceptionHandlerTest.cs (4)
191Assert.True(response.Content.Headers.TryGetValues("Expires", out values)); 247Assert.True(response.Content.Headers.TryGetValues("Expires", out values)); 303Assert.True(response.Content.Headers.TryGetValues("Expires", out values)); 445Assert.True(response.Content.Headers.TryGetValues("Expires", out values));
Microsoft.AspNetCore.HeaderPropagation (3)
HeaderPropagationMessageHandler.cs (3)
62!(hasContent && request.Content!.Headers.TryGetValues(entry.OutboundHeaderName, out var _))) 72request.Content!.Headers.TryAddWithoutValidation(entry.OutboundHeaderName, value); 80request.Content!.Headers.TryAddWithoutValidation(entry.OutboundHeaderName, values);
Microsoft.AspNetCore.HeaderPropagation.Tests (6)
HeaderPropagationMessageHandlerTest.cs (6)
78Assert.True(Handler.Content.Headers.Contains("Content-Type")); 79Assert.Equal(new[] { "text/plain; charset=utf-8" }, Handler.Content.Headers.GetValues("Content-Type")); 92Assert.True(Handler.Content.Headers.Contains("Content-Language")); 93Assert.Equal(new[] { "test" }, Handler.Content.Headers.GetValues("Content-Language")); 106Assert.True(Handler.Content.Headers.Contains("Content-Language")); 107Assert.Equal(new[] { "one", "two" }, Handler.Content.Headers.GetValues("Content-Language"));
Microsoft.AspNetCore.Http.Connections.Client (1)
Internal\LongPollingTransport.Log.cs (1)
49response.Content.Headers.ContentLength ?? -1);
Microsoft.AspNetCore.HttpLogging.Tests (2)
HttpLoggingMiddlewareTests.cs (2)
1777request.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("text/plain"); 1867request.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("text/plain");
Microsoft.AspNetCore.Identity.FunctionalTests (8)
Extensions\HttpClientExtensions.cs (1)
57submision.Content.Headers.TryAddWithoutValidation(header.Key, header.Value);
Extensions\ResponseAssert.cs (2)
24Assert.Equal("text/html", response.Content.Headers.ContentType.MediaType); 37MapHeaders(response.Content.Headers);
MapIdentityApiTests.cs (5)
1431Assert.Equal(0, response.Content.Headers.ContentLength); 1437Assert.Equal(0, response.Content.Headers.ContentLength); 1443Assert.Equal(0, response.Content.Headers.ContentLength); 1449Assert.Equal("application/problem+json", response.Content.Headers.ContentType?.ToString()); 1459Assert.Equal("application/problem+json", response.Content.Headers.ContentType?.ToString());
Microsoft.AspNetCore.Identity.InMemory.Test (2)
FunctionalTest.cs (2)
455transaction.Response.Content.Headers.ContentType != null && 456transaction.Response.Content.Headers.ContentType.MediaType == "text/xml")
Microsoft.AspNetCore.InternalTesting (2)
HttpClientSlim.cs (2)
82await writer.WriteAsync($"Content-Type: {content.Headers.ContentType}\r\n").ConfigureAwait(false); 83await writer.WriteAsync($"Content-Length: {content.Headers.ContentLength}\r\n").ConfigureAwait(false);
Microsoft.AspNetCore.Mvc.FunctionalTests (212)
ApiBehaviorTest.cs (2)
62Assert.Equal("application/problem+json", response.Content.Headers.ContentType.MediaType); 451Assert.Equal("application/vnd.error+json", response.Content.Headers.ContentType.MediaType);
BasicTests.cs (11)
56Assert.Equal(expectedMediaType, response.Content.Headers.ContentType); 76Assert.Equal(expectedMediaType, response.Content.Headers.ContentType); 100Assert.Equal(expectedMediaType, response.Content.Headers.ContentType); 120Assert.Equal(expectedMediaType, response.Content.Headers.ContentType); 152Assert.Null(response.Content.Headers.ContentType); 153Assert.Equal(0, response.Content.Headers.ContentLength); 196Assert.Equal(0, response.Content.Headers.ContentLength); 212Assert.Equal(0, response.Content.Headers.ContentLength); 246Assert.Equal("text/html", response.Content.Headers.ContentType.MediaType); 269Assert.Equal("text/html", response.Content.Headers.ContentType.MediaType); 292Assert.Equal("text/html", response.Content.Headers.ContentType.MediaType);
ContentNegotiationTest.cs (21)
49Assert.Equal(expectedContentType, response.Content.Headers.ContentType); 66Assert.Equal(expectedContentType, response.Content.Headers.ContentType); 82Assert.Equal(expectedContentType, response.Content.Headers.ContentType); 97Assert.Equal(expectedContentType, response.Content.Headers.ContentType); 117Assert.Equal(expectedContentType, response.Content.Headers.ContentType); 136Assert.Equal(expectedContentType, response.Content.Headers.ContentType); 161Assert.Equal(expectedContentType, response.Content.Headers.ContentType); 179Assert.Equal(expectedContentType, response.Content.Headers.ContentType); 221var contentType = response.Content.Headers.ContentType; 242Assert.Equal(expectedContentType, response.Content.Headers.ContentType); 260Assert.Equal(expectedContentType, response.Content.Headers.ContentType); 277Assert.Equal(expectedContentType, response.Content.Headers.ContentType); 294Assert.Equal(expectedContentType, response.Content.Headers.ContentType); 312Assert.Equal(expectedContentType, response.Content.Headers.ContentType); 328Assert.Equal(expectedContentType, response.Content.Headers.ContentType); 353Assert.Equal(expectedContentType, response.Content.Headers.ContentType); 375Assert.Equal("text/plain; charset=utf-8", response.Content.Headers.ContentType.ToString()); 393Assert.Equal("application/json; charset=utf-8", response.Content.Headers.ContentType.ToString()); 496Assert.Equal(expectedMediaType, response.Content.Headers.ContentType); 514Assert.Equal(expectedMediaType, response.Content.Headers.ContentType); 535Assert.Equal("application/xml; charset=utf-8", response.Content.Headers.ContentType.ToString());
CustomValueProviderTest.cs (4)
51Assert.Equal("text/plain", response.Content.Headers.ContentType.MediaType); 68Assert.Equal("application/json", response.Content.Headers.ContentType.MediaType); 85Assert.Equal("application/json", response.Content.Headers.ContentType.MediaType); 102Assert.Equal("application/json", response.Content.Headers.ContentType.MediaType);
DoNotRespectBrowserAcceptHeaderTests.cs (8)
52Assert.NotNull(response.Content.Headers.ContentType); 53Assert.Equal("application/json; charset=utf-8", response.Content.Headers.ContentType.ToString()); 80Assert.NotNull(response.Content.Headers.ContentType); 81Assert.Equal("application/xml; charset=utf-8", response.Content.Headers.ContentType.ToString()); 109Assert.NotNull(response.Content.Headers.ContentType); 112Assert.Equal("application/json; charset=utf-8", response.Content.Headers.ContentType.ToString()); 140Assert.NotNull(response.Content.Headers.ContentType); 141Assert.Equal("application/xml; charset=utf-8", response.Content.Headers.ContentType.ToString());
ErrorPageTests.cs (5)
67Assert.Equal(expectedMediaType, response.Content.Headers.ContentType); 102Assert.Equal(expectedMediaType, response.Content.Headers.ContentType); 123Assert.Equal(expectedMediaType, response.Content.Headers.ContentType); 143Assert.Equal(expectedMediaType, response.Content.Headers.ContentType); 161Assert.Equal(expectedMediaType, response.Content.Headers.ContentType);
FileResultTests.cs (100)
44Assert.NotNull(response.Content.Headers.ContentType); 45Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 67Assert.NotNull(response.Content.Headers.ContentType); 68Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 89Assert.NotNull(response.Content.Headers.ContentType); 90Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 109Assert.NotNull(response.Content.Headers.ContentType); 110Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 111Assert.Equal(0, response.Content.Headers.ContentLength); 131Assert.NotNull(response.Content.Headers.ContentType); 132Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 153Assert.NotNull(response.Content.Headers.ContentType); 154Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 173Assert.NotNull(response.Content.Headers.ContentType); 174Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 175Assert.Equal(0, response.Content.Headers.ContentLength); 191Assert.NotNull(response.Content.Headers.ContentType); 192Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 198var contentDisposition = response.Content.Headers.ContentDisposition.ToString(); 217Assert.NotNull(response.Content.Headers.ContentType); 218Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 236Assert.NotNull(response.Content.Headers.ContentType); 237Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 256Assert.NotNull(response.Content.Headers.ContentType); 257Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 289Assert.NotNull(response.Content.Headers.ContentType); 290Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 296var contentLength = response.Content.Headers.ContentLength; 299var contentDisposition = response.Content.Headers.ContentDisposition.ToString(); 314Assert.NotNull(response.Content.Headers.ContentType); 315Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 331Assert.NotNull(response.Content.Headers.ContentType); 332Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 353Assert.NotNull(response.Content.Headers.ContentType); 354Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 376Assert.NotNull(response.Content.Headers.ContentType); 377Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 397Assert.NotNull(response.Content.Headers.ContentType); 398Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 399Assert.Equal(0, response.Content.Headers.ContentLength); 412Assert.NotNull(response.Content.Headers.ContentType); 413Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 419var contentDisposition = response.Content.Headers.ContentDisposition.ToString(); 438Assert.NotNull(response.Content.Headers.ContentType); 439Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 457Assert.NotNull(response.Content.Headers.ContentType); 458Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 508Assert.NotNull(response.Content.Headers.ContentType); 509Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 515var contentLength = response.Content.Headers.ContentLength; 518var contentDisposition = response.Content.Headers.ContentDisposition.ToString(); 532Assert.NotNull(response.Content.Headers.ContentType); 533Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 555Assert.NotNull(response.Content.Headers.ContentType); 556Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 577Assert.NotNull(response.Content.Headers.ContentType); 578Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 597Assert.NotNull(response.Content.Headers.ContentType); 598Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 601Assert.NotNull(response.Content.Headers.ContentType); 602Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 603Assert.Equal(0, response.Content.Headers.ContentLength); 616Assert.NotNull(response.Content.Headers.ContentType); 617Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 623var contentDisposition = response.Content.Headers.ContentDisposition.ToString(); 642Assert.NotNull(response.Content.Headers.ContentType); 643Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 661Assert.NotNull(response.Content.Headers.ContentType); 662Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 681Assert.NotNull(response.Content.Headers.ContentType); 682Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 714Assert.NotNull(response.Content.Headers.ContentType); 715Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 721var contentLength = response.Content.Headers.ContentLength; 724var contentDisposition = response.Content.Headers.ContentDisposition.ToString(); 741Assert.NotNull(response.Content.Headers.ContentType); 742Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 748var contentDisposition = response.Content.Headers.ContentDisposition.ToString(); 768Assert.NotNull(response.Content.Headers.ContentType); 769Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 773var contentDisposition = response.Content.Headers.ContentDisposition.ToString(); 792Assert.NotNull(response.Content.Headers.ContentType); 793Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 811Assert.NotNull(response.Content.Headers.ContentType); 812Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 816var contentDisposition = response.Content.Headers.ContentDisposition.ToString(); 834Assert.NotNull(response.Content.Headers.ContentType); 835Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 838var contentDisposition = response.Content.Headers.ContentDisposition.ToString(); 858Assert.NotNull(response.Content.Headers.ContentType); 859Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 862var contentDisposition = response.Content.Headers.ContentDisposition.ToString(); 881Assert.NotNull(response.Content.Headers.ContentType); 882Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 883Assert.Equal(0, response.Content.Headers.ContentLength); 886var contentDisposition = response.Content.Headers.ContentDisposition.ToString(); 918Assert.NotNull(response.Content.Headers.ContentType); 919Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 925var contentLength = response.Content.Headers.ContentLength; 928var contentDisposition = response.Content.Headers.ContentDisposition.ToString();
HtmlGenerationTest.cs (5)
114Assert.Equal(expectedMediaType, response.Content.Headers.ContentType); 139Assert.Equal(expectedMediaType, response.Content.Headers.ContentType); 231Assert.Equal(expectedMediaType, response.Content.Headers.ContentType); 271Assert.Equal(expectedMediaType, response.Content.Headers.ContentType); 310Assert.Equal(expectedMediaType, response.Content.Headers.ContentType);
InputFormatterTests.cs (8)
227Assert.Null(content.Headers.ContentType); 228Assert.Equal(0, content.Headers.ContentLength); 272Assert.Null(content.Headers.ContentType); 273Assert.Equal(0, content.Headers.ContentLength); 287Assert.Null(content.Headers.ContentType); 288Assert.Equal(0, content.Headers.ContentLength); 302Assert.Null(content.Headers.ContentType); 303Assert.Equal(0, content.Headers.ContentLength);
JsonInputFormatterTestBase.cs (1)
204content.Headers.Clear();
JsonResultWithNewtonsoftJsonTest.cs (5)
51Assert.Equal("application/json", response.Content.Headers.ContentType.MediaType); 73Assert.Equal("application/json", response.Content.Headers.ContentType.MediaType); 91Assert.Equal("application/json", response.Content.Headers.ContentType.MediaType); 109Assert.Equal("application/json", response.Content.Headers.ContentType.MediaType); 142Assert.Equal("application/message+json", response.Content.Headers.ContentType.MediaType);
JsonResultWithSystemTextJsonTest.cs (5)
51Assert.Equal("application/json", response.Content.Headers.ContentType.MediaType); 73Assert.Equal("application/json", response.Content.Headers.ContentType.MediaType); 91Assert.Equal("application/json", response.Content.Headers.ContentType.MediaType); 109Assert.Equal("application/json", response.Content.Headers.ContentType.MediaType); 142Assert.Equal("application/message+json", response.Content.Headers.ContentType.MediaType);
LinkGenerationTests.cs (1)
88Assert.Equal(expectedMediaType, response.Content.Headers.ContentType);
NewtonsoftJsonOutputFormatterTest.cs (1)
47Assert.Equal(50, response.Content.Headers.ContentLength);
OutputFormatterTest.cs (7)
46Assert.Equal(expectedContentType, response.Content.Headers.ContentType); 63Assert.Equal(expectedContentType, response.Content.Headers.ContentType); 75Assert.Null(response.Content.Headers.ContentType); 80Assert.Equal(0, response.Content.Headers.ContentLength); 93Assert.Null(response.Content.Headers.ContentType); 98Assert.Equal(0, response.Content.Headers.ContentLength); 113Assert.Null(response.Content.Headers.ContentType);
RazorPagesTest.cs (5)
56Assert.Equal(expectedMediaType, response.Content.Headers.ContentType); 898Assert.NotNull(response.Content.Headers.ContentType); 899Assert.Equal("text/html", response.Content.Headers.ContentType.MediaType); 914Assert.NotNull(response.Content.Headers.ContentType); 915Assert.Equal("text/html", response.Content.Headers.ContentType.MediaType);
RemoteAttributeValidationTest.cs (6)
49Assert.Equal("text/html", response.Content.Headers.ContentType.MediaType); 50Assert.Equal("utf-8", response.Content.Headers.ContentType.CharSet); 74Assert.Equal("application/json", response.Content.Headers.ContentType.MediaType); 75Assert.Equal("utf-8", response.Content.Headers.ContentType.CharSet); 103Assert.Equal("application/json", response.Content.Headers.ContentType.MediaType); 104Assert.Equal("utf-8", response.Content.Headers.ContentType.CharSet);
RespectBrowserAcceptHeaderTests.cs (4)
52Assert.NotNull(response.Content.Headers.ContentType); 53Assert.Equal("application/json; charset=utf-8", response.Content.Headers.ContentType.ToString()); 71Assert.NotNull(response.Content.Headers.ContentType); 72Assert.Equal("text/plain; charset=utf-8", response.Content.Headers.ContentType.ToString());
SerializableErrorTests.cs (4)
60Assert.NotNull(response.Content.Headers.ContentType); 61Assert.Equal(acceptHeader, response.Content.Headers.ContentType.MediaType); 84Assert.NotNull(response.Content.Headers.ContentType); 85Assert.Equal(acceptHeader, response.Content.Headers.ContentType.MediaType);
SimpleWithWebApplicationBuilderTests.cs (2)
234request.Content.Headers.ContentType = new("application/xml"); 249request.Content.Headers.ContentType = new("application/xml");
StreamOutputFormatterTest.cs (1)
42Assert.Equal(contentType, response.Content.Headers.ContentType?.ToString());
TagHelpersTest.cs (3)
62Assert.Equal(expectedMediaType, response.Content.Headers.ContentType); 99Assert.Equal(expectedMediaType, response.Content.Headers.ContentType); 120Assert.Equal(expectedMediaType, response.Content.Headers.ContentType);
TestingInfrastructureTests.cs (1)
83Assert.True(request.Content.Headers.TryAddWithoutValidation("X-Invalid-Content-Header", "Bearer 1234,5678"));
XmlOutputFormatterTests.cs (2)
55Assert.Equal(167, response.Content.Headers.ContentLength); 76Assert.Equal(149, response.Content.Headers.ContentLength);
Microsoft.AspNetCore.Mvc.Testing (3)
Handlers\RedirectHandler.cs (3)
88foreach (var header in originalRequestContent.Headers) 90contentCopy.Headers.TryAddWithoutValidation(header.Key, header.Value); 91newRequestContent.Headers.TryAddWithoutValidation(header.Key, header.Value);
Microsoft.AspNetCore.OutputCaching.Tests (5)
OutputCacheTests.cs (5)
1004var len = resp.Content.Headers.ContentLength; 1042Assert.Equal(initialResponse.Content.Headers.ContentLocation, subsequentResponse.Content.Headers.ContentLocation); 1045Assert.Equal(initialResponse.Content.Headers.Expires, subsequentResponse.Content.Headers.Expires);
Microsoft.AspNetCore.RequestDecompression.Tests (6)
RequestDecompressionMiddlewareTests.cs (6)
241request.Content.Headers.ContentEncoding.Add(contentEncoding); 312request.Content.Headers.ContentEncoding.Add(contentEncoding); 388request.Content.Headers.ContentEncoding.Add(contentEncoding); 490request.Content.Headers.ContentEncoding.Add(contentEncoding); 574request.Content.Headers.ContentEncoding.Add(contentEncoding); 730request.Content.Headers.ContentEncoding.Add(encoding);
Microsoft.AspNetCore.ResponseCaching.Tests (4)
ResponseCachingTests.cs (4)
946Assert.Equal(initialResponse.Content.Headers.ContentLocation, subsequentResponse.Content.Headers.ContentLocation); 949Assert.Equal(initialResponse.Content.Headers.Expires, subsequentResponse.Content.Headers.Expires);
Microsoft.AspNetCore.ResponseCompression.Tests (21)
ResponseCompressionMiddlewareTest.cs (21)
424Assert.True(response.Content.Headers.ContentEncoding.Contains(otherContentEncoding)); 425Assert.False(response.Content.Headers.ContentEncoding.Contains("gzip")); 426Assert.Equal(50, response.Content.Headers.ContentLength); 755Assert.False(response.Content.Headers.TryGetValues(HeaderNames.ContentMD5, out _)); 756Assert.Single(response.Content.Headers.ContentEncoding, encoding); 808Assert.False(response.Content.Headers.TryGetValues(HeaderNames.ContentMD5, out _)); 809Assert.Single(response.Content.Headers.ContentEncoding, encoding); 877Assert.False(response.Content.Headers.TryGetValues(HeaderNames.ContentMD5, out _)); 878Assert.Single(response.Content.Headers.ContentEncoding, encoding); 941Assert.False(response.Content.Headers.TryGetValues(HeaderNames.ContentMD5, out _)); 942Assert.Single(response.Content.Headers.ContentEncoding, encoding); 1005Assert.True(response.Content.Headers.TryGetValues(HeaderNames.ContentMD5, out var md5)); 1007Assert.Empty(response.Content.Headers.ContentEncoding); 1217Assert.False(response.Content.Headers.TryGetValues(HeaderNames.ContentMD5, out _)); 1218Assert.Single(response.Content.Headers.ContentEncoding, encoding); 1301Assert.False(response.Content.Headers.TryGetValues(HeaderNames.ContentMD5, out _)); 1302Assert.Single(response.Content.Headers.ContentEncoding, expectedEncoding); 1303Assert.Equal(expectedBodyLength, response.Content.Headers.ContentLength); 1325Assert.NotNull(response.Content.Headers.GetValues(HeaderNames.ContentMD5)); 1326Assert.Empty(response.Content.Headers.ContentEncoding); 1327Assert.Equal(expectedBodyLength, response.Content.Headers.ContentLength);
Microsoft.AspNetCore.Routing.FunctionalTests (10)
Benchmarks\EndpointRoutingBenchmarkTest.cs (2)
51Assert.NotNull(response.Content.Headers.ContentType); 52Assert.Equal(expectedContentType, response.Content.Headers.ContentType.MediaType);
Benchmarks\RouterBenchmarkTest.cs (2)
52Assert.NotNull(response.Content.Headers.ContentType); 53Assert.Equal(expectedContentType, response.Content.Headers.ContentType.MediaType);
EndpointRoutingSampleTest.cs (6)
58Assert.NotNull(response.Content.Headers.ContentType); 59Assert.Equal(expectedContentType, response.Content.Headers.ContentType.MediaType); 75Assert.NotNull(response.Content.Headers.ContentType); 76Assert.Equal(expectedContentType, response.Content.Headers.ContentType.MediaType); 94Assert.NotNull(response.Content.Headers.ContentType); 95Assert.Equal(expectedContentType, response.Content.Headers.ContentType.MediaType);
Microsoft.AspNetCore.Server.HttpSys.FunctionalTests (51)
Listener\ResponseBodyTests.cs (3)
46Assert.False(response.Content.Headers.TryGetValues("content-length", out ignored), "Content-Length"); 70Assert.False(response.Content.Headers.TryGetValues("content-length", out contentLength), "Content-Length"); 95Assert.False(response.Content.Headers.TryGetValues("content-length", out ignored), "Content-Length");
Listener\ResponseHeaderTests.cs (14)
44Assert.Single(response.Content.Headers); 45Assert.Equal(0, response.Content.Headers.ContentLength); 67Assert.Single(response.Content.Headers); 68Assert.Equal(0, response.Content.Headers.ContentLength); 89Assert.False(response.Content.Headers.Contains("Content-Length")); 90Assert.Empty(response.Content.Headers); 118Assert.False(response.Content.Headers.Contains("Content-Length")); 119Assert.Empty(response.Content.Headers); 147Assert.Single(response.Content.Headers); 148Assert.Equal(20, response.Content.Headers.ContentLength); 176Assert.False(response.Content.Headers.Contains("Content-Length")); 177Assert.Empty(response.Content.Headers); 199Assert.False(response.Content.Headers.Contains("Content-Length")); 200Assert.Empty(response.Content.Headers);
OpaqueUpgradeTests.cs (2)
42Assert.Equal(0, response.Content.Headers.ContentLength); 70Assert.Equal(0, response.Content.Headers.ContentLength);
ResponseBodyTests.cs (11)
36Assert.False(response.Content.Headers.TryGetValues("content-length", out ignored), "Content-Length"); 64Assert.Equal(0, response.Content.Headers.ContentLength); 123Assert.False(response.Content.Headers.TryGetValues("content-length", out ignored), "Content-Length"); 155Assert.False(response.Content.Headers.TryGetValues("content-length", out ignored), "Content-Length"); 180Assert.False(response.Content.Headers.TryGetValues("content-length", out ignored), "Content-Length"); 202Assert.False(response.Content.Headers.TryGetValues("content-length", out ignored), "Content-Length"); 226Assert.True(response.Content.Headers.TryGetValues("content-length", out contentLength), "Content-Length"); 306Assert.True(response.Content.Headers.TryGetValues("content-length", out contentLength), "Content-Length"); 338Assert.False(response.Content.Headers.TryGetValues("content-length", out ignored), "Content-Length"); 366Assert.False(response.Content.Headers.TryGetValues("content-length", out ignored), "Content-Length"); 393Assert.False(response.Content.Headers.TryGetValues("content-length", out ignored), "Content-Length");
ResponseCachingTests.cs (2)
477Assert.Equal(10, response.Content.Headers.ContentLength); 490Assert.Equal(_fileLength, response.Content.Headers.ContentLength);
ResponseHeaderTests.cs (4)
35Assert.Single(response.Content.Headers); 36Assert.Equal(0, response.Content.Headers.ContentLength); 156var result = response.Content.Headers.TryGetValues("Content-Length", out values); 205Assert.False(response.Content.Headers.Contains("Content-Length"));
ResponseSendFileTests.cs (11)
74Assert.False(response.Content.Headers.TryGetValues("content-length", out ignored), "Content-Length"); 93Assert.False(response.Content.Headers.TryGetValues("content-length", out ignored), "Content-Length"); 112Assert.False(response.Content.Headers.TryGetValues("content-length", out contentLength), "Content-Length"); 132Assert.False(response.Content.Headers.TryGetValues("content-length", out contentLength), "Content-Length"); 151Assert.False(response.Content.Headers.TryGetValues("content-length", out contentLength), "Content-Length"); 208Assert.False(response.Content.Headers.TryGetValues("content-length", out contentLength), "Content-Length"); 228Assert.True(response.Content.Headers.TryGetValues("content-length", out contentLength), "Content-Length"); 249Assert.True(response.Content.Headers.TryGetValues("content-length", out contentLength), "Content-Length"); 270Assert.True(response.Content.Headers.TryGetValues("content-length", out contentLength), "Content-Length"); 299Assert.False(response.Content.Headers.TryGetValues("content-length", out ignored), "Content-Length"); 322Assert.False(response.Content.Headers.TryGetValues("content-length", out var contentLength), "Content-Length");
ResponseTrailersTests.cs (4)
140Assert.Equal(body.Length.ToString(CultureInfo.InvariantCulture), response.Content.Headers.GetValues(HeaderNames.ContentLength).Single()); 164Assert.True(response.Content.Headers.TryGetValues(HeaderNames.ContentLength, out var contentLength), HeaderNames.ContentLength); 189Assert.True(response.Content.Headers.TryGetValues(HeaderNames.ContentLength, out var contentLength), HeaderNames.ContentLength); 215Assert.True(response.Content.Headers.TryGetValues(HeaderNames.ContentLength, out var contentLength), HeaderNames.ContentLength);
Microsoft.AspNetCore.SpaServices.Extensions (2)
Proxying\SpaProxy.cs (2)
154requestMessage.Content?.Headers.TryAddWithoutValidation(header.Key, header.Value.ToArray()); 178foreach (var header in responseMessage.Content.Headers)
Microsoft.AspNetCore.StaticAssets.Tests (16)
StaticAssetsIntegrationTests.cs (16)
65Assert.Equal(13, response.Content.Headers.ContentLength); 66Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 115Assert.Equal(13, response.Content.Headers.ContentLength); 116Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 167Assert.Equal(13, response.Content.Headers.ContentLength); 168Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 336Assert.Equal(13, response.Content.Headers.ContentLength); 337Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 389Assert.Equal(22, response.Content.Headers.ContentLength); 390Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 445Assert.Equal(55, response.Content.Headers.ContentLength); 446Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 764Assert.NotNull(response.Content.Headers.LastModified); 766Assert.Equal(response.Content.Headers.LastModified.Value.Offset, TimeSpan.Zero); 788req2.Headers.IfModifiedSince = resp1.Content.Headers.LastModified; 825var lastModified = resp1.Content.Headers.LastModified.Value;
Microsoft.AspNetCore.StaticFiles.FunctionalTests (6)
StaticFileMiddlewareTests.cs (6)
113Assert.Equal(response.Content.Headers.LastModified.Value, trimmed); 163Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 164Assert.True(response.Content.Headers.ContentLength == fileInfo.Length); 165Assert.Equal(response.Content.Headers.ContentLength, responseContent.Length); 205Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 206Assert.True(response.Content.Headers.ContentLength == fileInfo.Length);
Microsoft.AspNetCore.StaticFiles.Tests (86)
CacheHeaderTests.cs (4)
170Assert.NotNull(response.Content.Headers.LastModified); 172Assert.Equal(response.Content.Headers.LastModified.Value.Offset, TimeSpan.Zero); 197.And(req => req.Headers.IfModifiedSince = resp1.Content.Headers.LastModified) 239DateTimeOffset lastModified = resp1.Content.Headers.LastModified.Value;
DirectoryBrowserMiddlewareTests.cs (8)
171Assert.Equal("text/html; charset=utf-8", response.Content.Headers.ContentType.ToString()); 172Assert.True(response.Content.Headers.ContentLength > 0); 173Assert.Equal(response.Content.Headers.ContentLength, (await response.Content.ReadAsByteArrayAsync()).Length); 228Assert.Equal("text/html; charset=utf-8", response.Content.Headers.ContentType.ToString()); 229Assert.True(response.Content.Headers.ContentLength > 0); 230Assert.Equal(response.Content.Headers.ContentLength, (await response.Content.ReadAsByteArrayAsync()).Length); 371Assert.Equal("text/html; charset=utf-8", response.Content.Headers.ContentType.ToString()); 372Assert.Null(response.Content.Headers.ContentLength);
RangeHeaderTests.cs (54)
28Assert.Equal("bytes 0-10/62", resp.Content.Headers.ContentRange.ToString()); 29Assert.Equal(11, resp.Content.Headers.ContentLength); 51Assert.Null(resp.Content.Headers.ContentRange); 52Assert.Equal(62, resp.Content.Headers.ContentLength); 66req.Headers.Add("If-Range", original.Content.Headers.LastModified.Value.ToString("r")); 70Assert.Equal("bytes 0-10/62", resp.Content.Headers.ContentRange.ToString()); 71Assert.Equal(11, resp.Content.Headers.ContentLength); 83req.Headers.Add("If-Modified-Since", original.Content.Headers.LastModified.Value.AddHours(-1).ToString("r")); 87Assert.Equal("bytes 0-10/62", resp.Content.Headers.ContentRange.ToString()); 88Assert.Equal(11, resp.Content.Headers.ContentLength); 100req.Headers.Add("If-Modified-Since", original.Content.Headers.LastModified.Value.ToString("r")); 117req.Headers.Add("If-Range", original.Content.Headers.LastModified.Value.ToString("r")); 122Assert.Equal(original.Content.Headers.LastModified, resp.Content.Headers.LastModified); 123Assert.Null(resp.Content.Headers.ContentRange); 124Assert.Equal(62, resp.Content.Headers.ContentLength); 140Assert.Null(resp.Content.Headers.ContentRange); 141Assert.Equal(62, resp.Content.Headers.ContentLength); 157Assert.Null(resp.Content.Headers.ContentRange); 158Assert.Equal(62, resp.Content.Headers.ContentLength); 172req.Headers.Add("If-Range", original.Content.Headers.LastModified.Value.Subtract(TimeSpan.FromDays(1)).ToString("r")); 176Assert.Null(resp.Content.Headers.ContentRange); 177Assert.Equal(62, resp.Content.Headers.ContentLength); 191req.Headers.Add("If-Range", original.Content.Headers.LastModified.Value.Subtract(TimeSpan.FromDays(1)).ToString("r")); 195Assert.Null(resp.Content.Headers.ContentRange); 196Assert.Equal(62, resp.Content.Headers.ContentLength); 214Assert.Null(resp.Content.Headers.ContentRange); 215Assert.Equal(62, resp.Content.Headers.ContentLength); 219req.Headers.Add("If-Range", original.Content.Headers.LastModified.Value.ToString("r")); 222Assert.Null(resp.Content.Headers.ContentRange); 223Assert.Equal(62, resp.Content.Headers.ContentLength); 241Assert.Null(resp.Content.Headers.ContentRange); 242Assert.Equal(62, resp.Content.Headers.ContentLength); 246req.Headers.Add("If-Range", original.Content.Headers.LastModified.Value.ToString("r")); 249Assert.Null(resp.Content.Headers.ContentRange); 250Assert.Equal(62, resp.Content.Headers.ContentLength); 274Assert.NotNull(resp.Content.Headers.ContentRange); 275Assert.Equal("bytes " + expectedRange + "/62", resp.Content.Headers.ContentRange.ToString()); 276Assert.Equal(length, resp.Content.Headers.ContentLength); 295Assert.NotNull(resp.Content.Headers.ContentRange); 296Assert.Equal("bytes " + expectedRange + "/1", resp.Content.Headers.ContentRange.ToString()); 297Assert.Equal(length, resp.Content.Headers.ContentLength); 330Assert.Null(resp.Content.Headers.ContentRange); 331Assert.Equal(62, resp.Content.Headers.ContentLength); 348Assert.Equal("bytes */62", resp.Content.Headers.ContentRange.ToString()); 363Assert.Null(resp.Content.Headers.ContentRange); 383Assert.Null(resp.Content.Headers.ContentRange); 384Assert.Equal(62, resp.Content.Headers.ContentLength); 405Assert.Null(resp.Content.Headers.ContentRange); 406Assert.Equal(62, resp.Content.Headers.ContentLength); 426Assert.Equal("text/plain", resp.Content.Headers.ContentType.ToString()); 427Assert.Null(resp.Content.Headers.ContentRange); 428Assert.Equal(62, resp.Content.Headers.ContentLength); 446Assert.Equal("text/plain", resp.Content.Headers.ContentType.ToString());
StaticFileMiddlewareTests.cs (20)
134Assert.Equal(response.Content.Headers.LastModified.Value, trimmed); 190Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 191Assert.True(response.Content.Headers.ContentLength == fileInfo.Length); 192Assert.Equal(response.Content.Headers.ContentLength, responseContent.Length); 229Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 230Assert.True(response.Content.Headers.ContentLength == fileInfo.Length); 231Assert.Equal(response.Content.Headers.ContentLength, responseContent.Length); 271Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 272Assert.True(response.Content.Headers.ContentLength == fileInfo.Length); 273Assert.Equal(response.Content.Headers.ContentLength, responseContent.Length); 321Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 322Assert.True(response.Content.Headers.ContentLength == fileInfo.Length); 323Assert.Equal(response.Content.Headers.ContentLength, responseContent.Length); 364Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 365Assert.True(response.Content.Headers.ContentLength == fileInfo.Length); 366Assert.Equal(response.Content.Headers.ContentLength, responseContent.Length); 412Assert.Equal("text/customfortest+plain", response.Content.Headers.ContentType.ToString()); 482Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 483Assert.True(response.Content.Headers.ContentLength == fileInfo.Length); 539Assert.Null(response.Content.Headers.LastModified);
Microsoft.AspNetCore.TestHost (5)
ClientHandler.cs (4)
127var contentLength = requestContent.Headers.ContentLength; 142requestContent.Headers.Remove(HeaderNames.ContentLength); 145foreach (var header in requestContent.Headers) 223bool success = response.Content.Headers.TryAddWithoutValidation(header.Key, (IEnumerable<string>)header.Value);
RequestBuilder.cs (1)
58if (!_req.Content.Headers.TryAddWithoutValidation(name, value))
Microsoft.AspNetCore.TestHost.Tests (1)
RequestBuilderTests.cs (1)
33Assert.Equal("Test/Value", request.Content.Headers.ContentType.ToString());
Microsoft.AspNetCore.Tests (3)
WebApplicationTests.cs (3)
2042Assert.Contains("text/plain", response.Content.Headers.ContentType.MediaType); 2147Assert.Contains("text/plain", response.Content.Headers.ContentType.MediaType); 2172Assert.Null(response.Content.Headers.ContentType);
Microsoft.Build.Tasks.Core (6)
DownloadFile.cs (6)
193Log.LogErrorFromResources("DownloadFile.Downloading", SourceUrl, destinationFile.FullName, response.Content.Headers.ContentLength); 203Log.LogMessageFromResources(MessageImportance.High, "DownloadFile.Downloading", SourceUrl, destinationFile.FullName, response.Content.Headers.ContentLength); 326: response.Content?.Headers?.ContentDisposition?.FileName // Attempt to get the file name from the content-disposition header value 353&& destinationFile.Length == response.Content.Headers.ContentLength 354&& response.Content.Headers.LastModified.HasValue 355&& destinationFile.LastWriteTimeUtc > response.Content.Headers.LastModified.Value.UtcDateTime;
Microsoft.Extensions.Http (4)
Logging\LogHelper.cs (4)
108new HttpHeadersLogValue(HttpHeadersLogValue.Kind.Request, request.Headers, request.Content?.Headers, shouldRedactHeaderValue), 123new HttpHeadersLogValue(HttpHeadersLogValue.Kind.Response, response.Headers, response.Content?.Headers, shouldRedactHeaderValue), 147new HttpHeadersLogValue(HttpHeadersLogValue.Kind.Request, request.Headers, request.Content?.Headers, shouldRedactHeaderValue), 162new HttpHeadersLogValue(HttpHeadersLogValue.Kind.Response, response.Headers, response.Content?.Headers, shouldRedactHeaderValue),
Microsoft.Extensions.Http.Diagnostics (6)
Logging\Internal\HttpHeadersReader.cs (2)
51ReadHeaders(request.Content.Headers, _requestHeadersToLog, destination); 69ReadHeaders(response.Content.Headers, _responseHeadersToLog, destination);
Logging\Internal\HttpRequestBodyReader.cs (1)
54var contentType = request.Content.Headers.ContentType;
Logging\Internal\HttpResponseBodyReader.cs (3)
46var contentType = response.Content.Headers.ContentType; 113foreach (var header in response.Content.Headers) 115_ = newContent.Headers.TryAddWithoutValidation(header.Key, header.Value);
Microsoft.Extensions.Http.Diagnostics.PerformanceTests (2)
NoRemoteCallHandler.cs (1)
44response.Content.Headers.ContentType = new("application/json");
NoRemoteCallNotSeekableHandler.cs (1)
47response.Content.Headers.ContentType = new("application/json");
Microsoft.Extensions.Http.Diagnostics.Tests (11)
Logging\HttpClientLoggerTest.cs (2)
860requestContent.Headers.Add("Content-Type", TextPlain); 871responseContent.Headers.Add("Content-Type", TextPlain);
Logging\HttpHeadersReaderTest.cs (6)
132requestContent.Headers.ContentType = new(MediaTypeNames.Application.Soap); 133requestContent.Headers.ContentLength = 42; 134requestContent.Headers.Add("Content-Header1", "Content.1"); 141responseContent.Headers.ContentType = new(MediaTypeNames.Text.Html); 142responseContent.Headers.ContentLength = 24; 143responseContent.Headers.Add("Content-Header2", "Content.2");
Logging\HttpRequestBodyReaderTest.cs (1)
189httpRequest.Content.Headers.Add("Content-type", "text/plain");
Logging\HttpResponseBodyReaderTest.cs (1)
157httpResponse.Content.Headers.Add("Content-type", "text/plain");
Logging\Internal\NoRemoteCallHandler.cs (1)
38response.Content.Headers.ContentType = new("application/json");
Microsoft.ML.PerformanceTests (1)
ImageClassificationBench.cs (1)
164var totalSizeInBytes = headerResponse.Content.Headers.ContentLength;
ServerComparison.FunctionalTests (5)
ResponseCompressionTests.cs (4)
175Assert.Empty(response.Content.Headers.ContentEncoding); 207Assert.Single(response.Content.Headers.ContentEncoding); 208Assert.Equal("gzip", response.Content.Headers.ContentEncoding.First()); 221return response.Content.Headers.TryGetValues(HeaderNames.ContentLength, out var values) ? values.FirstOrDefault() : null;
ResponseTests.cs (1)
270return response.Content.Headers.TryGetValues(HeaderNames.ContentLength, out values) ? values.FirstOrDefault() : null;
System.Net.Http (41)
System\Net\Http\FormUrlEncodedContent.cs (1)
23Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");
System\Net\Http\HttpClient.cs (3)
203using var buffer = new HttpContent.LimitArrayPoolWriteStream(_maxResponseContentBufferSize, (int)c.Headers.ContentLength.GetValueOrDefault()); 217return HttpContent.ReadBufferAsString(buffer.GetBuffer(), c.Headers); 282long? contentLength = c.Headers.ContentLength;
System\Net\Http\HttpContent.cs (2)
163return ReadBufferAsString(buffer, Headers); 657long? contentLength = Headers.ContentLength;
System\Net\Http\HttpRequestMessage.cs (1)
166HeaderUtilities.DumpHeaders(sb, _headers, _content?.Headers);
System\Net\Http\HttpResponseMessage.cs (1)
195HeaderUtilities.DumpHeaders(sb, _headers, _content?.Headers);
System\Net\Http\MultipartContent.cs (3)
59Headers.ContentType = contentType; 317foreach (KeyValuePair<string, HeaderStringValues> headerPair in content.Headers.NonValidated) 372foreach (KeyValuePair<string, HeaderStringValues> headerPair in content.Headers.NonValidated)
System\Net\Http\MultipartFormDataContent.cs (3)
30content.Headers.ContentDisposition ??= new ContentDispositionHeaderValue(formData); 54if (content.Headers.ContentDisposition == null) 61content.Headers.ContentDisposition = header;
System\Net\Http\SocketsHttpHandler\DecompressionHandler.cs (7)
72ICollection<string> contentEncodings = response.Content.Headers.ContentEncoding; 121Headers.AddHeaders(originalContent.Headers); 122Headers.ContentLength = null; 123Headers.ContentEncoding.Clear(); 125foreach (string encoding in originalContent.Headers.ContentEncoding) 129Headers.ContentEncoding.Add(prevEncoding);
System\Net\Http\SocketsHttpHandler\Http2Connection.cs (1)
1558headerListSize += WriteHeaderCollection(request, request.Content.Headers, ref headerBuffer);
System\Net\Http\SocketsHttpHandler\Http2Stream.cs (2)
210using var writeStream = new Http2WriteStream(this, _request.Content.Headers.ContentLength.GetValueOrDefault(-1)); 718_response.Content.Headers.TryAddWithoutValidation(descriptor, headerValue);
System\Net\Http\SocketsHttpHandler\Http3RequestStream.cs (5)
240bool useEmptyResponseContent = responseContent.Headers.ContentLength == 0 && sendContentObserved; 444_requestContentLengthRemaining = content.Headers.ContentLength ?? -1; 456long contentLength = content.Headers.ContentLength.GetValueOrDefault(); 683headerListSize += BufferHeaderCollection(request.Content.Headers); 1091_response!.Content!.Headers.TryAddWithoutValidation(descriptor, headerValue);
System\Net\Http\SocketsHttpHandler\HttpConnection.cs (7)
383WriteHeaderCollection(content.Headers); 727(request.Content.Headers.ContentLength == null || request.Content.Headers.ContentLength.GetValueOrDefault() > Expect100ErrorSendThreshold) && 813else if (response.Content.Headers.ContentLength != null) 815long contentLength = response.Content.Headers.ContentLength.GetValueOrDefault(); 948new ContentLengthWriteStream(this, request.Content.Headers.ContentLength.GetValueOrDefault()); 1304headers = response.Content!.Headers;
System\Net\Http\SocketsHttpHandler\SocketsHttpHandler.cs (2)
649request.Content.Headers.ContentLength = null; 651else if (request.Content != null && request.Content.Headers.ContentLength == null)
System\Net\Http\StringContent.cs (3)
68Headers.TryAddWithoutValidation(KnownHeaders.ContentType.Descriptor, knownValue); 73Headers.ContentType = new MediaTypeHeaderValue(mediaType, encoding.WebName); 83Headers.ContentType = mediaType;
System.Net.Http.Json (4)
System\Net\Http\Json\HttpClientJsonExtensions.cs (1)
124if (response.Content.Headers.ContentLength is long contentLength && contentLength > contentLengthLimit)
System\Net\Http\Json\JsonContent.cs (2)
35Headers.ContentType = mediaType; 39Headers.TryAddWithoutValidation("Content-Type", JsonHelpers.DefaultMediaType);
System\Net\Http\Json\JsonHelpers.cs (1)
34if (content.Headers.ContentType?.CharSet is string charset)
System.Net.Requests (5)
System\Net\HttpWebRequest.cs (1)
1201_sendRequestMessage.Content.Headers.TryAddWithoutValidation(headerName, _webHeaderCollection[headerName!]);
System\Net\HttpWebResponse.cs (4)
86return _httpResponseMessage.Content?.Headers.ContentLength ?? -1; 99if (_httpResponseMessage.Content != null && _httpResponseMessage.Content.Headers.TryGetValues("Content-Type", out IEnumerable<string>? values)) 119return GetHeaderValueAsString(_httpResponseMessage.Content.Headers.ContentEncoding); 210foreach (var header in _httpResponseMessage.Content.Headers)
System.ServiceModel.Http (26)
System\ServiceModel\Channels\HttpChannelFactory.cs (1)
1025var contentType = httpRequestMessage.Content.Headers.ContentType;
System\ServiceModel\Channels\HttpRequestMessageExtensionMethods.cs (2)
74MergeWebHeaderCollectionWithHttpHeaders(headersToMerge, requestMessage.Headers, requestMessage.Content.Headers); 97headers = headers.Concat(httpRequest.Content.Headers);
System\ServiceModel\Channels\HttpRequestMessageProperty.cs (5)
307long? contentLength = content.Headers.ContentLength; 323(!content.Headers.ContentLength.HasValue || 324content.Headers.ContentLength.Value > 0)) 327foreach (KeyValuePair<string, IEnumerable<string>> header in content.Headers) 329newContent.Headers.AddHeaderWithoutValidation(header);
System\ServiceModel\Channels\HttpResponseMessageExtensionMethods.cs (2)
34HttpRequestMessageExtensionMethods.MergeWebHeaderCollectionWithHttpHeaders(headersToMerge, responseMessage.Headers, responseMessage.Content.Headers); 42headers = headers.Concat(httpResponse.Content.Headers);
System\ServiceModel\Channels\HttpResponseMessageHelper.cs (7)
135var mediaValueContentType = content.Headers.ContentType; 137_contentLength = content.Headers.ContentLength.HasValue ? content.Headers.ContentLength.Value : -1; 179if (!content.Headers.ContentLength.HasValue) 312_contentLength = content.Headers.ContentLength.HasValue ? content.Headers.ContentLength.Value : -1; 366throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ProtocolException(SR.Format(SR.FramingContentTypeMismatch, _httpRequestMessage.Content.Headers.ContentType.ToString(), _httpRequestMessage.RequestUri)));
System\ServiceModel\Channels\HttpResponseMessageProperty.cs (5)
331long? contentLength = content.Headers.ContentLength; 347(!content.Headers.ContentLength.HasValue || 348content.Headers.ContentLength.Value > 0)) 351foreach (KeyValuePair<string, IEnumerable<string>> header in content.Headers) 353newContent.Headers.AddHeaderWithoutValidation(header);
System\ServiceModel\Channels\MessageContent.cs (4)
102var actionParams = (from p in Headers.ContentType.Parameters where p.Name == "action" select p).ToArray(); 119new ProtocolException(SR.Format(SR.HttpContentTypeFormatException, formatException.Message, Headers.ContentType.ToString()), formatException)); 126Headers.ContentType.Parameters.Add(new NameValueHeaderValue("action", action)); 138Headers.ContentType = contentTypeHeaderValue;
Templates.Blazor.Tests (1)
BlazorWebTemplateTest.cs (1)
93Assert.Equal(expectedEncoding, response.Content.Headers.ContentEncoding.Single());