2 writes to Headers
Microsoft.Build.Tasks.UnitTests (2)
DownloadFile_Tests.cs (2)
96Headers = 327Headers =
663 references to Headers
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)
371requestContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("text/plain");
Microsoft.AspNetCore.Authentication.OpenIdConnect (4)
OpenIdConnectHandler.cs (4)
886var contentMediaType = responseMessage.Content.Headers.ContentType?.MediaType; 895Logger.LogDebug($"Unexpected token response format. Status Code: {(int)responseMessage.StatusCode}. Content-Type {responseMessage.Content.Headers.ContentType}."); 911throw new OpenIdConnectProtocolException($"Failed to parse token response body as JSON. Status Code: {(int)responseMessage.StatusCode}. Content-Type: {responseMessage.Content.Headers.ContentType}", ex); 955var 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)
1297transaction.Response.Content.Headers.ContentType != null && 1298transaction.Response.Content.Headers.ContentType.MediaType == "text/xml")
OpenIdConnect\OpenIdConnectChallengeTests.cs (1)
162Assert.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.Grpc.JsonTranscoding.IntegrationTests (10)
RouteTests.cs (1)
242content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json");
UnaryTests.cs (9)
180content.Headers.ContentType = MediaTypeHeaderValue.Parse(contentType); 188Assert.Equal("application/json", response.Content.Headers.ContentType!.MediaType); 189Assert.Equal(encoding?.WebName ?? "utf-8", response.Content.Headers.ContentType!.CharSet); 213content.Headers.ContentType = MediaTypeHeaderValue.Parse(contentType); 221Assert.Equal("application/json", response.Content.Headers.ContentType!.MediaType); 222Assert.Equal("utf-8", response.Content.Headers.ContentType!.CharSet); 242content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json"); 250Assert.Equal("application/json", response.Content.Headers.ContentType!.MediaType); 251Assert.Equal("utf-8", response.Content.Headers.ContentType!.CharSet);
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)
50Assert.Equal("application/problem+json", response.Content.Headers.ContentType.MediaType); 449Assert.Equal("application/vnd.error+json", response.Content.Headers.ContentType.MediaType);
BasicTests.cs (11)
45Assert.Equal(expectedMediaType, response.Content.Headers.ContentType); 65Assert.Equal(expectedMediaType, response.Content.Headers.ContentType); 89Assert.Equal(expectedMediaType, response.Content.Headers.ContentType); 109Assert.Equal(expectedMediaType, response.Content.Headers.ContentType); 141Assert.Null(response.Content.Headers.ContentType); 142Assert.Equal(0, response.Content.Headers.ContentLength); 185Assert.Equal(0, response.Content.Headers.ContentLength); 201Assert.Equal(0, response.Content.Headers.ContentLength); 235Assert.Equal("text/html", response.Content.Headers.ContentType.MediaType); 258Assert.Equal("text/html", response.Content.Headers.ContentType.MediaType); 281Assert.Equal("text/html", response.Content.Headers.ContentType.MediaType);
ContentNegotiationTest.cs (21)
37Assert.Equal(expectedContentType, response.Content.Headers.ContentType); 54Assert.Equal(expectedContentType, response.Content.Headers.ContentType); 70Assert.Equal(expectedContentType, response.Content.Headers.ContentType); 85Assert.Equal(expectedContentType, response.Content.Headers.ContentType); 105Assert.Equal(expectedContentType, response.Content.Headers.ContentType); 124Assert.Equal(expectedContentType, response.Content.Headers.ContentType); 149Assert.Equal(expectedContentType, response.Content.Headers.ContentType); 167Assert.Equal(expectedContentType, response.Content.Headers.ContentType); 209var contentType = response.Content.Headers.ContentType; 230Assert.Equal(expectedContentType, response.Content.Headers.ContentType); 248Assert.Equal(expectedContentType, response.Content.Headers.ContentType); 265Assert.Equal(expectedContentType, response.Content.Headers.ContentType); 282Assert.Equal(expectedContentType, response.Content.Headers.ContentType); 300Assert.Equal(expectedContentType, response.Content.Headers.ContentType); 316Assert.Equal(expectedContentType, response.Content.Headers.ContentType); 341Assert.Equal(expectedContentType, response.Content.Headers.ContentType); 363Assert.Equal("text/plain; charset=utf-8", response.Content.Headers.ContentType.ToString()); 381Assert.Equal("application/json; charset=utf-8", response.Content.Headers.ContentType.ToString()); 484Assert.Equal(expectedMediaType, response.Content.Headers.ContentType); 502Assert.Equal(expectedMediaType, response.Content.Headers.ContentType); 523Assert.Equal("application/xml; charset=utf-8", response.Content.Headers.ContentType.ToString());
CustomValueProviderTest.cs (4)
39Assert.Equal("text/plain", response.Content.Headers.ContentType.MediaType); 56Assert.Equal("application/json", response.Content.Headers.ContentType.MediaType); 73Assert.Equal("application/json", response.Content.Headers.ContentType.MediaType); 90Assert.Equal("application/json", response.Content.Headers.ContentType.MediaType);
DoNotRespectBrowserAcceptHeaderTests.cs (8)
38Assert.NotNull(response.Content.Headers.ContentType); 39Assert.Equal("application/json; charset=utf-8", response.Content.Headers.ContentType.ToString()); 66Assert.NotNull(response.Content.Headers.ContentType); 67Assert.Equal("application/xml; charset=utf-8", response.Content.Headers.ContentType.ToString()); 95Assert.NotNull(response.Content.Headers.ContentType); 98Assert.Equal("application/json; charset=utf-8", response.Content.Headers.ContentType.ToString()); 126Assert.NotNull(response.Content.Headers.ContentType); 127Assert.Equal("application/xml; charset=utf-8", response.Content.Headers.ContentType.ToString());
ErrorPageTests.cs (5)
69Assert.Equal(expectedMediaType, response.Content.Headers.ContentType); 104Assert.Equal(expectedMediaType, response.Content.Headers.ContentType); 125Assert.Equal(expectedMediaType, response.Content.Headers.ContentType); 145Assert.Equal(expectedMediaType, response.Content.Headers.ContentType); 163Assert.Equal(expectedMediaType, response.Content.Headers.ContentType);
FileResultTests.cs (100)
31Assert.NotNull(response.Content.Headers.ContentType); 32Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 54Assert.NotNull(response.Content.Headers.ContentType); 55Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 76Assert.NotNull(response.Content.Headers.ContentType); 77Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 96Assert.NotNull(response.Content.Headers.ContentType); 97Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 98Assert.Equal(0, response.Content.Headers.ContentLength); 118Assert.NotNull(response.Content.Headers.ContentType); 119Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 140Assert.NotNull(response.Content.Headers.ContentType); 141Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 160Assert.NotNull(response.Content.Headers.ContentType); 161Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 162Assert.Equal(0, response.Content.Headers.ContentLength); 178Assert.NotNull(response.Content.Headers.ContentType); 179Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 185var contentDisposition = response.Content.Headers.ContentDisposition.ToString(); 204Assert.NotNull(response.Content.Headers.ContentType); 205Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 223Assert.NotNull(response.Content.Headers.ContentType); 224Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 243Assert.NotNull(response.Content.Headers.ContentType); 244Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 276Assert.NotNull(response.Content.Headers.ContentType); 277Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 283var contentLength = response.Content.Headers.ContentLength; 286var contentDisposition = response.Content.Headers.ContentDisposition.ToString(); 301Assert.NotNull(response.Content.Headers.ContentType); 302Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 318Assert.NotNull(response.Content.Headers.ContentType); 319Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 340Assert.NotNull(response.Content.Headers.ContentType); 341Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 363Assert.NotNull(response.Content.Headers.ContentType); 364Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 384Assert.NotNull(response.Content.Headers.ContentType); 385Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 386Assert.Equal(0, response.Content.Headers.ContentLength); 399Assert.NotNull(response.Content.Headers.ContentType); 400Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 406var contentDisposition = response.Content.Headers.ContentDisposition.ToString(); 425Assert.NotNull(response.Content.Headers.ContentType); 426Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 444Assert.NotNull(response.Content.Headers.ContentType); 445Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 495Assert.NotNull(response.Content.Headers.ContentType); 496Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 502var contentLength = response.Content.Headers.ContentLength; 505var contentDisposition = response.Content.Headers.ContentDisposition.ToString(); 519Assert.NotNull(response.Content.Headers.ContentType); 520Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 542Assert.NotNull(response.Content.Headers.ContentType); 543Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 564Assert.NotNull(response.Content.Headers.ContentType); 565Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 584Assert.NotNull(response.Content.Headers.ContentType); 585Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 588Assert.NotNull(response.Content.Headers.ContentType); 589Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 590Assert.Equal(0, response.Content.Headers.ContentLength); 603Assert.NotNull(response.Content.Headers.ContentType); 604Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 610var contentDisposition = response.Content.Headers.ContentDisposition.ToString(); 629Assert.NotNull(response.Content.Headers.ContentType); 630Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 648Assert.NotNull(response.Content.Headers.ContentType); 649Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 668Assert.NotNull(response.Content.Headers.ContentType); 669Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 701Assert.NotNull(response.Content.Headers.ContentType); 702Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 708var contentLength = response.Content.Headers.ContentLength; 711var contentDisposition = response.Content.Headers.ContentDisposition.ToString(); 728Assert.NotNull(response.Content.Headers.ContentType); 729Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 735var contentDisposition = response.Content.Headers.ContentDisposition.ToString(); 755Assert.NotNull(response.Content.Headers.ContentType); 756Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 760var contentDisposition = response.Content.Headers.ContentDisposition.ToString(); 779Assert.NotNull(response.Content.Headers.ContentType); 780Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 798Assert.NotNull(response.Content.Headers.ContentType); 799Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 803var contentDisposition = response.Content.Headers.ContentDisposition.ToString(); 821Assert.NotNull(response.Content.Headers.ContentType); 822Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 825var contentDisposition = response.Content.Headers.ContentDisposition.ToString(); 845Assert.NotNull(response.Content.Headers.ContentType); 846Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 849var contentDisposition = response.Content.Headers.ContentDisposition.ToString(); 868Assert.NotNull(response.Content.Headers.ContentType); 869Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 870Assert.Equal(0, response.Content.Headers.ContentLength); 873var contentDisposition = response.Content.Headers.ContentDisposition.ToString(); 905Assert.NotNull(response.Content.Headers.ContentType); 906Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 912var contentLength = response.Content.Headers.ContentLength; 915var contentDisposition = response.Content.Headers.ContentDisposition.ToString();
HtmlGenerationTest.cs (5)
109Assert.Equal(expectedMediaType, response.Content.Headers.ContentType); 134Assert.Equal(expectedMediaType, response.Content.Headers.ContentType); 226Assert.Equal(expectedMediaType, response.Content.Headers.ContentType); 266Assert.Equal(expectedMediaType, response.Content.Headers.ContentType); 305Assert.Equal(expectedMediaType, response.Content.Headers.ContentType);
InputFormatterTests.cs (8)
215Assert.Null(content.Headers.ContentType); 216Assert.Equal(0, content.Headers.ContentLength); 260Assert.Null(content.Headers.ContentType); 261Assert.Equal(0, content.Headers.ContentLength); 275Assert.Null(content.Headers.ContentType); 276Assert.Equal(0, content.Headers.ContentLength); 290Assert.Null(content.Headers.ContentType); 291Assert.Equal(0, content.Headers.ContentLength);
JsonInputFormatterTestBase.cs (1)
192content.Headers.Clear();
JsonResultWithNewtonsoftJsonTest.cs (5)
39Assert.Equal("application/json", response.Content.Headers.ContentType.MediaType); 61Assert.Equal("application/json", response.Content.Headers.ContentType.MediaType); 79Assert.Equal("application/json", response.Content.Headers.ContentType.MediaType); 97Assert.Equal("application/json", response.Content.Headers.ContentType.MediaType); 130Assert.Equal("application/message+json", response.Content.Headers.ContentType.MediaType);
JsonResultWithSystemTextJsonTest.cs (5)
39Assert.Equal("application/json", response.Content.Headers.ContentType.MediaType); 61Assert.Equal("application/json", response.Content.Headers.ContentType.MediaType); 79Assert.Equal("application/json", response.Content.Headers.ContentType.MediaType); 97Assert.Equal("application/json", response.Content.Headers.ContentType.MediaType); 130Assert.Equal("application/message+json", response.Content.Headers.ContentType.MediaType);
LinkGenerationTests.cs (1)
75Assert.Equal(expectedMediaType, response.Content.Headers.ContentType);
NewtonsoftJsonOutputFormatterTest.cs (1)
52Assert.Equal(50, response.Content.Headers.ContentLength);
OutputFormatterTest.cs (7)
34Assert.Equal(expectedContentType, response.Content.Headers.ContentType); 51Assert.Equal(expectedContentType, response.Content.Headers.ContentType); 63Assert.Null(response.Content.Headers.ContentType); 68Assert.Equal(0, response.Content.Headers.ContentLength); 81Assert.Null(response.Content.Headers.ContentType); 86Assert.Equal(0, response.Content.Headers.ContentLength); 101Assert.Null(response.Content.Headers.ContentType);
RazorPagesTest.cs (5)
45Assert.Equal(expectedMediaType, response.Content.Headers.ContentType); 887Assert.NotNull(response.Content.Headers.ContentType); 888Assert.Equal("text/html", response.Content.Headers.ContentType.MediaType); 903Assert.NotNull(response.Content.Headers.ContentType); 904Assert.Equal("text/html", response.Content.Headers.ContentType.MediaType);
RemoteAttributeValidationTest.cs (6)
38Assert.Equal("text/html", response.Content.Headers.ContentType.MediaType); 39Assert.Equal("utf-8", response.Content.Headers.ContentType.CharSet); 63Assert.Equal("application/json", response.Content.Headers.ContentType.MediaType); 64Assert.Equal("utf-8", response.Content.Headers.ContentType.CharSet); 92Assert.Equal("application/json", response.Content.Headers.ContentType.MediaType); 93Assert.Equal("utf-8", response.Content.Headers.ContentType.CharSet);
RespectBrowserAcceptHeaderTests.cs (4)
39Assert.NotNull(response.Content.Headers.ContentType); 40Assert.Equal("application/json; charset=utf-8", response.Content.Headers.ContentType.ToString()); 58Assert.NotNull(response.Content.Headers.ContentType); 59Assert.Equal("text/plain; charset=utf-8", response.Content.Headers.ContentType.ToString());
SerializableErrorTests.cs (4)
48Assert.NotNull(response.Content.Headers.ContentType); 49Assert.Equal(acceptHeader, response.Content.Headers.ContentType.MediaType); 72Assert.NotNull(response.Content.Headers.ContentType); 73Assert.Equal(acceptHeader, response.Content.Headers.ContentType.MediaType);
SimpleWithWebApplicationBuilderTests.cs (2)
232request.Content.Headers.ContentType = new("application/xml"); 247request.Content.Headers.ContentType = new("application/xml");
StreamOutputFormatterTest.cs (1)
30Assert.Equal(contentType, response.Content.Headers.ContentType?.ToString());
TagHelpersTest.cs (3)
53Assert.Equal(expectedMediaType, response.Content.Headers.ContentType); 90Assert.Equal(expectedMediaType, response.Content.Headers.ContentType); 111Assert.Equal(expectedMediaType, response.Content.Headers.ContentType);
TestingInfrastructureTests.cs (1)
84Assert.True(request.Content.Headers.TryAddWithoutValidation("X-Invalid-Content-Header", "Bearer 1234,5678"));
XmlOutputFormatterTests.cs (2)
42Assert.Equal(167, response.Content.Headers.ContentLength); 63Assert.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)
43Assert.Single(response.Content.Headers); 44Assert.Equal(0, response.Content.Headers.ContentLength); 66Assert.Single(response.Content.Headers); 67Assert.Equal(0, response.Content.Headers.ContentLength); 88Assert.False(response.Content.Headers.Contains("Content-Length")); 89Assert.Empty(response.Content.Headers); 117Assert.False(response.Content.Headers.Contains("Content-Length")); 118Assert.Empty(response.Content.Headers); 146Assert.Single(response.Content.Headers); 147Assert.Equal(20, response.Content.Headers.ContentLength); 175Assert.False(response.Content.Headers.Contains("Content-Length")); 176Assert.Empty(response.Content.Headers); 198Assert.False(response.Content.Headers.Contains("Content-Length")); 199Assert.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)
462Assert.Equal(10, response.Content.Headers.ContentLength); 475Assert.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)
73Assert.False(response.Content.Headers.TryGetValues("content-length", out ignored), "Content-Length"); 92Assert.False(response.Content.Headers.TryGetValues("content-length", out ignored), "Content-Length"); 111Assert.False(response.Content.Headers.TryGetValues("content-length", out contentLength), "Content-Length"); 131Assert.False(response.Content.Headers.TryGetValues("content-length", out contentLength), "Content-Length"); 150Assert.False(response.Content.Headers.TryGetValues("content-length", out contentLength), "Content-Length"); 207Assert.False(response.Content.Headers.TryGetValues("content-length", out contentLength), "Content-Length"); 227Assert.True(response.Content.Headers.TryGetValues("content-length", out contentLength), "Content-Length"); 248Assert.True(response.Content.Headers.TryGetValues("content-length", out contentLength), "Content-Length"); 269Assert.True(response.Content.Headers.TryGetValues("content-length", out contentLength), "Content-Length"); 298Assert.False(response.Content.Headers.TryGetValues("content-length", out ignored), "Content-Length"); 321Assert.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 (12)
StaticAssetsIntegrationTests.cs (12)
66Assert.Equal(13, response.Content.Headers.ContentLength); 67Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 120Assert.Equal(13, response.Content.Headers.ContentLength); 121Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 173Assert.Equal(22, response.Content.Headers.ContentLength); 174Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 229Assert.Equal(55, response.Content.Headers.ContentLength); 230Assert.Equal("text/plain", response.Content.Headers.ContentType.ToString()); 543Assert.NotNull(response.Content.Headers.LastModified); 545Assert.Equal(response.Content.Headers.LastModified.Value.Offset, TimeSpan.Zero); 567req2.Headers.IfModifiedSince = resp1.Content.Headers.LastModified; 604var 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\LoggingHttpMessageHandler.cs (2)
126new HttpHeadersLogValue(HttpHeadersLogValue.Kind.Request, request.Headers, request.Content?.Headers, shouldRedactHeaderValue), 141new HttpHeadersLogValue(HttpHeadersLogValue.Kind.Response, response.Headers, response.Content?.Headers, shouldRedactHeaderValue),
Logging\LoggingScopeHttpMessageHandler.cs (2)
128new HttpHeadersLogValue(HttpHeadersLogValue.Kind.Request, request.Headers, request.Content?.Headers, shouldRedactHeaderValue), 143new HttpHeadersLogValue(HttpHeadersLogValue.Kind.Response, response.Headers, response.Content?.Headers, shouldRedactHeaderValue),
ServerComparison.FunctionalTests (5)
ResponseCompressionTests.cs (4)
175Assert.Equal(0, response.Content.Headers.ContentEncoding.Count); 207Assert.Equal(1, response.Content.Headers.ContentEncoding.Count); 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); 634long? 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)
1559headerListSize += 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)
215bool useEmptyResponseContent = responseContent.Headers.ContentLength == 0 && sendContentObserved; 413_requestContentLengthRemaining = content.Headers.ContentLength ?? -1; 425long contentLength = content.Headers.ContentLength.GetValueOrDefault(); 653headerListSize += BufferHeaderCollection(request.Content.Headers); 1061_response!.Content!.Headers.TryAddWithoutValidation(descriptor, headerValue);
System\Net\Http\SocketsHttpHandler\HttpConnection.cs (7)
347WriteHeaderCollection(content.Headers); 689(request.Content.Headers.ContentLength == null || request.Content.Headers.ContentLength.GetValueOrDefault() > Expect100ErrorSendThreshold) && 775else if (response.Content.Headers.ContentLength != null) 777long contentLength = response.Content.Headers.ContentLength.GetValueOrDefault(); 910new ContentLengthWriteStream(this, request.Content.Headers.ContentLength.GetValueOrDefault()); 1266headers = response.Content!.Headers;
System\Net\Http\SocketsHttpHandler\SocketsHttpHandler.cs (2)
629request.Content.Headers.ContentLength = null; 631else 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)
1199_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)
BlazorWasmTemplateTest.cs (1)
107Assert.Equal(expectedEncoding, response.Content.Headers.ContentEncoding.Single());