1 override of Headers
Microsoft.AspNetCore.Http (1)
Internal\DefaultHttpRequest.cs (1)
133public override IHeaderDictionary Headers
2 writes to Headers
Microsoft.AspNetCore.Http.Extensions.Tests (2)
ParameterBindingMethodCacheTests.cs (2)
239Headers = 270Headers =
810 references to Headers
Aspire.Dashboard (1)
Authentication\OtlpApiKey\OtlpApiKeyAuthenticationHandler.cs (1)
26if (Context.Request.Headers.TryGetValue(ApiKeyHeaderName, out var apiKey))
Aspire.Dashboard.Tests (1)
OtlpApiKeyAuthenticationHandlerTests.cs (1)
98httpContext.Request.Headers[OtlpApiKeyAuthenticationHandler.ApiKeyHeaderName] = otlpApiKeyHeader;
AzureAppServicesHostingStartupSample (2)
Startup.cs (2)
22await context.Response.WriteAsync("Host: " + context.Request.Headers.Host + Environment.NewLine); 40foreach (var header in context.Request.Headers)
AzureAppServicesSample (2)
Startup.cs (2)
33await context.Response.WriteAsync("Host: " + context.Request.Headers.Host + Environment.NewLine); 51foreach (var header in context.Request.Headers)
BasicWebSite (4)
BasicAuthenticationHandler.cs (1)
19if (!Request.Headers.ContainsKey("Authorization"))
Controllers\TestingController.cs (2)
44if (!Request.Headers.TryGetValue("X-Added-Header", out var value)) 70if (Request.Headers.TryGetValue("X-Added-Header", out var value))
RequestIdMiddleware.cs (1)
24var requestId = context.Request.Headers.RequestId;
ControllersFromServicesClassLibrary (1)
ControllerWithConstructorInjection.cs (1)
33ActionContext.HttpContext.Request.Headers["Test-Header"]);
DefaultBuilder.SampleApp (1)
Startup.cs (1)
23foreach (var header in context.Request.Headers)
GenericHostWebSite (2)
Controllers\TestingController.cs (2)
43if (!Request.Headers.TryGetValue("X-Added-Header", out var value)) 56if (Request.Headers.TryGetValue("X-Added-Header", out var value))
HeaderPropagationSample (2)
Startup.cs (2)
65foreach (var header in context.Request.Headers) 91foreach (var header in context.Request.Headers)
HttpAbstractions.SampleApp (4)
Program.cs (4)
20request.Headers.ContentType = "application/json"; 21request.Headers.UserAgent = "Edge"; 22request.Headers.Cookie = "cookie1=value1;cookie2=value2"; 23request.Headers["Custom"] = new[] { "Value1", "Value2" };
HttpLogging.Sample (1)
SampleHttpLoggingInterceptor.cs (1)
41foreach (var header in logContext.HttpContext.Request.Headers)
HttpOverridesSample (1)
Startup.cs (1)
21foreach (var header in context.Request.Headers)
IISSample (2)
Startup.cs (2)
47await context.Response.WriteAsync("Host: " + context.Request.Headers["Host"] + Environment.NewLine); 67foreach (var header in context.Request.Headers)
InMemory.FunctionalTests (38)
BadHttpRequestTests.cs (1)
166receivedHost = context.Request.Headers.Host;
ChunkedRequestTests.cs (3)
266Assert.False(request.Headers.ContainsKey("X-Trailer-Header")); 397Assert.False(request.Headers.ContainsKey("X-Trailer-Header")); 592Assert.True(string.IsNullOrEmpty(request.Headers["X-Trailer-Header"]));
Http2\Http2StreamTests.cs (5)
188Assert.False(context.Request.Headers.ContainsKey(HeaderNames.TransferEncoding)); 239Assert.False(context.Request.Headers.ContainsKey(HeaderNames.TransferEncoding)); 480Assert.False(context.Request.Headers.ContainsKey(InternalHeaderNames.Scheme)); 5782Assert.Equal("£", context.Request.Headers["X-Test"]); 5827Assert.Equal("£", context.Request.Headers["X-Test"]);
Http2\Http2TestBase.cs (6)
196foreach (var header in context.Request.Headers) 222foreach (var header in context.Request.Headers) 355Assert.False(context.Request.Headers.ContainsKey(InternalHeaderNames.Method)); 363Assert.False(context.Request.Headers.ContainsKey(InternalHeaderNames.Authority)); 364context.Response.Headers.Host = context.Request.Headers.Host; 371Assert.False(context.Request.Headers.ContainsKey(InternalHeaderNames.Path));
Http2\Http2WebSocketTests.cs (15)
26Assert.False(context.Request.Headers.TryGetValue(":protocol", out var _)); 30Assert.Equal("chat, superchat", context.Request.Headers.WebSocketSubProtocols); 31Assert.Equal("permessage-deflate", context.Request.Headers.SecWebSocketExtensions); 32Assert.Equal("13", context.Request.Headers.SecWebSocketVersion); 33Assert.Equal("http://www.example.com", context.Request.Headers.Origin); 88Assert.False(context.Request.Headers.TryGetValue(":protocol", out var _)); 92Assert.Equal("chat, superchat", context.Request.Headers.WebSocketSubProtocols); 93Assert.Equal("permessage-deflate", context.Request.Headers.SecWebSocketExtensions); 94Assert.Equal("13", context.Request.Headers.SecWebSocketVersion); 95Assert.Equal("http://www.example.com", context.Request.Headers.Origin); 164Assert.False(context.Request.Headers.TryGetValue(":protocol", out var _)); 168Assert.Equal("chat, superchat", context.Request.Headers.WebSocketSubProtocols); 169Assert.Equal("permessage-deflate", context.Request.Headers.SecWebSocketExtensions); 170Assert.Equal("13", context.Request.Headers.SecWebSocketVersion); 171Assert.Equal("http://www.example.com", context.Request.Headers.Origin);
Http3\Http3ConnectionTests.cs (1)
145receivedHeaders = context.Request.Headers[HeaderNames.Cookie];
Http3\Http3TestBase.cs (1)
111context.Response.Headers.Host = context.Request.Headers.Host;
RequestTests.cs (5)
1403if (context.Request.Headers != lastRequestHeaders) 1405lastRequestHeaders = context.Request.Headers; 2084customHeaderValue = context.Request.Headers["X-CustomHeader"]; 2201Assert.Equal("£", context.Request.Headers["X-Test"]); 2294Assert.Equal("£", context.Request.Headers["X-Test"]);
UpgradeTests.cs (1)
239Assert.Equal("chunked", context.Request.Headers.TransferEncoding);
InProcessWebSite (26)
src\Servers\IIS\IIS\test\testassets\InProcessWebSite\Startup.cs (25)
300Assert.NotNull(ctx.Request.Headers); 468if ((string[])ctx.Request.Headers[headerName] != Array.Empty<string>()) 472if (ctx.Request.Headers.TryGetValue(headerName, out var headerValue) || (string[])headerValue is not null) 479ctx.Request.Headers.Add(headerName, "test"); 480ctx.Request.Headers[headerName] = default; 481ctx.Request.Headers.Add(headerName, "test"); 482ctx.Request.Headers[headerName] = StringValues.Empty; 483ctx.Request.Headers.Add(headerName, "test"); 488ctx.Request.Headers.Add(headerName, "test"); 493ctx.Request.Headers[headerName] = default; 659if (ctx.Request.Headers.TryGetValue("Response-Content-Type", out var contentType)) 691if (ctx.Request.Headers.TryGetValue("Response-Content-Type", out var contentType)) 988ctx.Request.Headers.ContentLength = ctx.Request.Path.Value.Length; 1068ctx.Response.WriteAsync("Scheme:" + ctx.Request.Scheme + "; Original:" + ctx.Request.Headers["x-original-proto"]); 1115File.Delete(context.Request.Headers["ANCMRHPath"]); 1123return context.Response.WriteAsync(context.Request.Headers["ANCMRHPath"]); 1147var value = context.Request.Headers["foo"]; 1154var value = context.Request.Headers["foo"]; 1166Assert.True(ctx.Request.Headers.ContainsKey("Transfer-Encoding")); 1167Assert.Equal("gzip, chunked", ctx.Request.Headers["Transfer-Encoding"]); 1184Assert.True(ctx.Request.Headers.ContainsKey("Transfer-Encoding")); 1185Assert.Equal("gzip, chunked", ctx.Request.Headers["Transfer-Encoding"]); 1186Assert.False(ctx.Request.Headers.ContainsKey("Content-Length")); 1187Assert.True(ctx.Request.Headers.ContainsKey("X-Content-Length")); 1188Assert.Equal("5", ctx.Request.Headers["X-Content-Length"]);
src\Servers\IIS\IIS\test\testassets\InProcessWebSite\Startup.WebSockets.cs (1)
147string key = context.Request.Headers[Constants.Headers.SecWebSocketKey].ToString();
Interop.FunctionalTests (5)
Http3\Http3RequestTests.cs (3)
893requestHeaders.Add(context.Request.Headers.ToDictionary(k => k.Key, k => k.Value, StringComparer.OrdinalIgnoreCase)); 1468request1HeaderValue = context.Request.Headers.UserAgent; 1472request2HeaderValue = context.Request.Headers.UserAgent;
HttpClientHttp2InteropTests.cs (2)
1039Assert.Equal(oneKbString + i, context.Request.Headers["header" + i]); 1148Assert.Equal(oneKbString + i, context.Request.Headers["header" + i]);
InteropWebsite (1)
TestServiceImpl.cs (1)
137var encoding = context.GetHttpContext().Request.Headers.SingleOrDefault(h => string.Equals(h.Key, "grpc-encoding", StringComparison.OrdinalIgnoreCase)).Value.SingleOrDefault();
JwtSample (1)
Startup.cs (1)
50(context.HttpContext.WebSockets.IsWebSocketRequest || context.Request.Headers["Accept"] == "text/event-stream"))
Microsoft.AspNetCore.Antiforgery (1)
Internal\DefaultAntiforgeryTokenStore.cs (1)
47requestToken = httpContext.Request.Headers[_options.HeaderName];
Microsoft.AspNetCore.Antiforgery.Test (4)
DefaultAntiforgeryTokenStoreTest.cs (4)
106httpContext.Request.Headers.Add("header-name", "header-value"); 164httpContext.Request.Headers.Add("header-name", "header-value"); 218httpContext.Request.Headers.Add("header-name", "header-value"); 515context.Request.Headers.Cookie = $"{cookieName}={cookieValue}";
Microsoft.AspNetCore.Authentication.Cookies (1)
CookieAuthenticationEvents.cs (1)
108string.Equals(request.Headers.XRequestedWith, "XMLHttpRequest", StringComparison.Ordinal);
Microsoft.AspNetCore.Authentication.JwtBearer (1)
JwtBearerHandler.cs (1)
76string authorization = Request.Headers.Authorization.ToString();
Microsoft.AspNetCore.Authentication.Negotiate (1)
NegotiateHandler.cs (1)
97var authorizationHeader = Request.Headers.Authorization;
Microsoft.AspNetCore.Authentication.Negotiate.Test (2)
EventTests.cs (1)
464context.Request.Headers.Authorization = authorizationHeader;
NegotiateHandlerTests.cs (1)
488context.Request.Headers.Authorization = authorizationHeader;
Microsoft.AspNetCore.Components.Endpoints (1)
Rendering\EndpointHtmlRenderer.Streaming.cs (1)
308var accept = request.Headers.Accept;
Microsoft.AspNetCore.Components.WebAssembly.Server (1)
ContentEncodingNegotiator.cs (1)
41var accept = context.Request.Headers.AcceptEncoding;
Microsoft.AspNetCore.Components.WebAssembly.Server.Tests (9)
ContentEncodingNegotiatorTests.cs (9)
24httpContext.Request.Headers.Append(HeaderNames.AcceptEncoding, encoding); 46httpContext.Request.Headers.Append(HeaderNames.AcceptEncoding, encoding); 67httpContext.Request.Headers.Append(HeaderNames.AcceptEncoding, encoding); 90httpContext.Request.Headers.Append(HeaderNames.AcceptEncoding, encoding); 113httpContext.Request.Headers.Append(HeaderNames.AcceptEncoding, encoding); 136httpContext.Request.Headers.Append(HeaderNames.AcceptEncoding, encoding); 159httpContext.Request.Headers.Append(HeaderNames.AcceptEncoding, encoding); 181httpContext.Request.Headers.Append(HeaderNames.AcceptEncoding, encoding); 202httpContext.Request.Headers.Append(HeaderNames.AcceptEncoding, encoding);
Microsoft.AspNetCore.CookiePolicy.Test (16)
CookieChunkingTests.cs (9)
87context.Request.Headers["Cookie"] = new[] 118context.Request.Headers["Cookie"] = new[] 149context.Request.Headers["Cookie"] = new[] 170context.Request.Headers["Cookie"] = new[] 190context.Request.Headers["Cookie"] = new[] 211context.Request.Headers.Append("Cookie", "TestCookie=chunks-7;TestCookieC1=1;TestCookieC2=2;TestCookieC3=3;TestCookieC4=4;TestCookieC5=5;TestCookieC6=6;TestCookieC7=7"); 233context.Request.Headers.Append("Cookie", "TestCookie=chunks-7;TestCookieC1=1;TestCookieC2=2"); 251context.Request.Headers.Append("Cookie", "TestCookie=chunks-7;TestCookieC1=1;TestCookieC2=2;TestCookieC4=4"); 270httpContext.Request.Headers["Cookie"] = new[]
CookieConsentTests.cs (7)
132requestContext.Request.Headers.Cookie = ".AspNet.Consent=yes"; 155requestContext.Request.Headers.Cookie = ".AspNet.Consent=yes"; 178requestContext.Request.Headers.Cookie = ".AspNet.Consent=IAmATeapot"; 286requestContext.Request.Headers.Cookie = ".AspNet.Consent=yes"; 378requestContext.Request.Headers.Cookie = ".AspNet.Consent=yes"; 427requestContext.Request.Headers.Cookie = ".AspNet.Consent=yes"; 463requestContext.Request.Headers.Cookie = ".AspNet.Consent=yes";
Microsoft.AspNetCore.Cors (4)
Infrastructure\CorsMiddleware.cs (2)
107if (!context.Request.Headers.ContainsKey(CorsConstants.Origin)) 120var isCorsPreflightRequest = isOptionsRequest && context.Request.Headers.ContainsKey(CorsConstants.AccessControlRequestMethod);
Infrastructure\CorsService.cs (2)
68var requestHeaders = context.Request.Headers; 99var headers = context.Request.Headers;
Microsoft.AspNetCore.Cors.Test (20)
CorsMiddlewareTests.cs (17)
392httpContext.Request.Headers.Add(CorsConstants.Origin, new[] { "http://example.com" }); 421httpContext.Request.Headers.Add(CorsConstants.Origin, new[] { "http://example.com" }); 659httpContext.Request.Headers.Add(CorsConstants.Origin, new[] { OriginUrl }); 660httpContext.Request.Headers.Add(CorsConstants.AccessControlRequestMethod, new[] { "PUT" }); 700httpContext.Request.Headers.Add(CorsConstants.Origin, new[] { "http://example.com" }); 730httpContext.Request.Headers.Add(CorsConstants.Origin, new[] { "http://example.com" }); 758httpContext.Request.Headers.Add(CorsConstants.Origin, new[] { "http://example.com" }); 759httpContext.Request.Headers.Add(CorsConstants.AccessControlRequestMethod, new[] { "GET" }); 790httpContext.Request.Headers.Add(CorsConstants.Origin, new[] { "http://example.com" }); 791httpContext.Request.Headers.Add(CorsConstants.AccessControlRequestMethod, new[] { "GET" }); 822httpContext.Request.Headers.Add(CorsConstants.Origin, new[] { "http://example.com" }); 857httpContext.Request.Headers.Add(CorsConstants.Origin, new[] { "http://example.com" }); 894httpContext.Request.Headers.Add(CorsConstants.Origin, new[] { "http://example.com" }); 927httpContext.Request.Headers.Add(CorsConstants.Origin, new[] { "http://example.com" }); 957httpContext.Request.Headers.Add(CorsConstants.Origin, new[] { "http://example.com" }); 984httpContext.Request.Headers.Add(CorsConstants.Origin, new[] { "http://example.com" }); 1032httpContext.Request.Headers.Add(CorsConstants.Origin, new[] { "http://example.com" });
CorsServiceTests.cs (3)
958context.Request.Headers.Add(CorsConstants.Origin, new[] { origin }); 963context.Request.Headers.Add(CorsConstants.AccessControlRequestMethod, new[] { accessControlRequestMethod }); 968context.Request.Headers.Add(CorsConstants.AccessControlRequestHeaders, accessControlRequestHeaders);
Microsoft.AspNetCore.Diagnostics (3)
DeveloperExceptionPage\DeveloperExceptionPageMiddlewareImpl.cs (3)
242foreach (var pair in httpContext.Request.Headers) 265headers: httpContext.Request.Headers, 381Headers = request.Headers,
Microsoft.AspNetCore.Diagnostics.Middleware (2)
Logging\HttpLoggingRedactionInterceptor.cs (1)
129_requestHeadersReader.Read(context.Request.Headers, logContext.Parameters);
Logging\RequestHeadersLogEnricher.cs (1)
69if (request.Headers.TryGetValue(header.Key, out var headerValue) && !string.IsNullOrEmpty(headerValue))
Microsoft.AspNetCore.Diagnostics.Middleware.Tests (2)
Logging\RequestHeadersEnricherTests.cs (2)
47httpContextMock.SetupGet(c => c.Request.Headers).Returns(headers); 256httpContextMock.SetupGet(c => c.Request.Headers).Throws(new ObjectDisposedException(""));
Microsoft.AspNetCore.Grpc.JsonTranscoding (1)
Internal\JsonTranscodingServerCallContext.cs (1)
147foreach (var header in HttpContext.Request.Headers)
Microsoft.AspNetCore.Grpc.JsonTranscoding.Tests (5)
JsonTranscodingServerCallContextTests.cs (5)
40httpContext.Request.Headers.Append("TestName", "TestValue"); 41httpContext.Request.Headers.Append(":method", "GET"); 42httpContext.Request.Headers.Append("grpc-encoding", "identity"); 43httpContext.Request.Headers.Append("grpc-timeout", "1S"); 44httpContext.Request.Headers.Append("hello-bin", Convert.ToBase64String(new byte[] { 1, 2, 3 }));
Microsoft.AspNetCore.HeaderParsing (1)
HeaderParsingFeature.cs (1)
139if (feature.Context!.Request.Headers.TryGetValue(header.Name, out var values))
Microsoft.AspNetCore.HeaderParsing.Tests (9)
HeaderParsingExtensionsTests.cs (1)
110context.Request.Headers["Date"] = date;
HeaderParsingFeatureTests.cs (8)
49Context.Request.Headers["Date"] = date; 67Context.Request.Headers["Date"] = currentDate; 68Context.Request.Headers["Test"] = futureDate; 90Context.Request.Headers["Date"] = date; 139Context.Request.Headers["Date"] = "Not a date."; 178Context.Request.Headers[firstHeaderKey.Name] = DateTimeOffset.Now.ToString("R", CultureInfo.InvariantCulture); 179Context.Request.Headers[thirdHeaderKey.Name] = DateTimeOffset.Now.ToString("R", CultureInfo.InvariantCulture); 196Context.Request.Headers[HeaderNames.CacheControl] = "max-age=604800";
Microsoft.AspNetCore.HeaderPropagation (1)
HeaderPropagationMiddleware.cs (1)
71context.Request.Headers.TryGetValue(entry.InboundHeaderName, out var value);
Microsoft.AspNetCore.HeaderPropagation.Tests (8)
HeaderPropagationMiddlewareTest.cs (8)
40Context.Request.Headers.Add("in", "test"); 67Context.Request.Headers.Add("in", "test"); 82Context.Request.Headers.Add("in", "test"); 83Context.Request.Headers.Add("another", "test2"); 102Context.Request.Headers.Add("in", headerValue); 128Context.Request.Headers.Add("in", "value"); 146Context.Request.Headers.Add("in", "no"); 161Context.Request.Headers.Add("in", "no");
Microsoft.AspNetCore.HostFiltering (1)
HostFilteringMiddleware.cs (1)
84var host = context.Request.Headers.Host.ToString();
Microsoft.AspNetCore.HostFiltering.Tests (7)
HostFilteringMiddlewareTests.cs (7)
59ctx.Request.Headers.Remove(HeaderNames.Host); 65Assert.False(c.Request.Headers.TryGetValue(HeaderNames.Host, out var host)); 100ctx.Request.Headers.Host = ""; 106Assert.True(c.Request.Headers.TryGetValue(HeaderNames.Host, out var host)); 157ctx.Request.Headers.Host = hosturl; 209ctx.Request.Headers.Host = hosturl; 248ctx.Request.Headers.Host = currentHost;
Microsoft.AspNetCore.Hosting (2)
Internal\HostingApplicationDiagnostics.cs (2)
392var headers = httpContext.Request.Headers; 451[DynamicDependency(nameof(HttpRequest.Headers), typeof(HttpRequest))]
Microsoft.AspNetCore.Http.Connections.Tests (11)
HttpConnectionDispatcherTests.cs (10)
771context.Request.Headers["header1"] = "h1"; 772context.Request.Headers["header2"] = "h2"; 773context.Request.Headers["header3"] = "h3"; 819Assert.Equal(3, connectionHttpContext.Request.Headers.Count); 820Assert.Equal("h1", connectionHttpContext.Request.Headers["header1"]); 821Assert.Equal("h2", connectionHttpContext.Request.Headers["header2"]); 822Assert.Equal("h3", connectionHttpContext.Request.Headers["header3"]); 3223(context.HttpContext.WebSockets.IsWebSocketRequest || context.Request.Headers["Accept"] == "text/event-stream")) 3385(context.HttpContext.WebSockets.IsWebSocketRequest || context.Request.Headers["Accept"] == "text/event-stream")) 3758context.Request.Headers["Accept"] = "text/event-stream";
WebSocketsTests.cs (1)
374context.Request.Headers.Add(HeaderNames.WebSocketSubProtocols, providedSubProtocols.ToArray());
Microsoft.AspNetCore.Http.Extensions (3)
DefaultProblemDetailsWriter.cs (1)
29var acceptHeader = httpContext.Request.Headers.Accept.GetList<MediaTypeHeaderValue>();
HeaderDictionaryTypeExtensions.cs (1)
27return new RequestHeaders(request.Headers);
RequestDelegateFactory.cs (1)
98private static readonly MemberExpression HeadersExpr = Expression.Property(HttpRequestExpr, typeof(HttpRequest).GetProperty(nameof(HttpRequest.Headers))!);
Microsoft.AspNetCore.Http.Extensions.Tests (159)
HeaderDictionaryTypeExtensionsTest.cs (21)
14context.Request.Headers.ContentType = "text/plain"; 36context.Request.Headers.ContentType = "invalid"; 47context.Request.Headers.CacheControl = "max-age=604800"; 59context.Request.Headers.ContentDisposition = "form-data; name=\"fieldName\""; 71context.Request.Headers.IfRange = "\"etag1\""; 83context.Request.Headers.Range = "bytes=0-499"; 95context.Request.Headers.ETag = "\"123\""; 108context.Request.Headers.ETag = expected.ToString("r"); 119context.Request.Headers.ETag = $"{int.MaxValue + 1L}"; 130context.Request.Headers["custom"] = "valid"; 140context.Request.Headers["custom"] = "invalid"; 159context.Request.Headers["custom"] = "valid"; 168context.Request.Headers.Accept = "text/plain; q=0.9, text/other, */*"; 194context.Request.Headers.Accept = "invalid"; 205context.Request.Headers.Accept = "text/plain; q=0.5, text/html; q=0.8"; 217context.Request.Headers.Cookie = "cookie1=a,cookie2=b"; 229context.Request.Headers.ETag = "\"123\",\"456\""; 241context.Request.Headers.SetCookie = "cookie1=a,cookie2=b"; 253context.Request.Headers["custom"] = "valid"; 264context.Request.Headers["custom"] = "invalid"; 283context.Request.Headers["custom"] = "valid";
ParameterBindingMethodCacheTests.cs (4)
1082if (!int.TryParse(context.Request.Headers.ETag, out var val)) 1098if (!int.TryParse(context.Request.Headers.ETag, out var val)) 1117if (!int.TryParse(context.Request.Headers.ETag, out var val)) 1130if (!int.TryParse(context.Request.Headers.ETag, out var val))
ProblemDetailsDefaultWriterTest.cs (1)
686context.Request.Headers.Accept = contentType;
RequestDelegateFactoryTests.cs (22)
420if (!Uri.TryCreate(context.Request.Headers.Referer, UriKind.Absolute, out var uri)) 441if (!Uri.TryCreate(context.Request.Headers.Referer, UriKind.Absolute, out var uri)) 457if (!Uri.TryCreate(context.Request.Headers.Referer, UriKind.Absolute, out var uri)) 480if (!Uri.TryCreate(context.Request.Headers.Referer, UriKind.Absolute, out var uri)) 498if (!Uri.TryCreate(context.Request.Headers.Referer, UriKind.Absolute, out var uri)) 514if (!Uri.TryCreate(context.Request.Headers.Referer, UriKind.Absolute, out var uri)) 533if (!Uri.TryCreate(context.Request.Headers.Referer, UriKind.Absolute, out var uri)) 546if (!Uri.TryCreate(context.Request.Headers.Referer, UriKind.Absolute, out var uri)) 564if (!Uri.TryCreate(context.Request.Headers.Referer, UriKind.Absolute, out var uri)) 633httpContext.Request.Headers["Custom"] = new(new[] { "4", "5", "6" }); 692httpContext.Request.Headers.Referer = "https://example.org"; 854httpContext.Request.Headers["Content-Type"] = "application/json"; 855httpContext.Request.Headers["Content-Length"] = stream.Length.ToString(CultureInfo.InvariantCulture); 887httpContext.Request.Headers["Content-Type"] = "application/json"; 888httpContext.Request.Headers["Content-Length"] = "0"; 1667httpContext.Request.Headers.Referer = "https://example.org"; 1934httpContext.Request.Headers["Content-Type"] = "application/x-www-form-urlencoded"; 1935httpContext.Request.Headers["Content-Length"] = "1"; 1967httpContext.Request.Headers["Content-Type"] = "application/json"; 1968httpContext.Request.Headers["Content-Length"] = "1000"; 2879httpContext.Request.Headers["Content-Type"] = "application/json"; 2880httpContext.Request.Headers["Content-Length"] = stream.Length.ToString(CultureInfo.InvariantCulture);
RequestDelegateGenerator\CompileTimeCreationTests.cs (1)
528httpContext.Request.Headers[value] = value;
RequestDelegateGenerator\RequestDelegateCreationTestBase.cs (2)
223httpContext.Request.Headers["Content-Type"] = "application/json"; 228httpContext.Request.Headers["Content-Length"] = stream.Length.ToString(CultureInfo.InvariantCulture);
RequestDelegateGenerator\RequestDelegateCreationTests.Arrays.cs (14)
57httpContext.Request.Headers.Add("p", new StringValues(new string[] { "1", "1" })); 78httpContext.Request.Headers.Add("p", new StringValues(new string[] { "1", "1" })); 99httpContext.Request.Headers.Add("p", new StringValues(new string[] { "1", "1" })); 623httpContext.Request.Headers["Content-Type"] = "application/json"; 627httpContext.Request.Headers["Content-Length"] = stream.Length.ToString(CultureInfo.InvariantCulture); 650httpContext.Request.Headers["Content-Type"] = "application/json"; 654httpContext.Request.Headers["Content-Length"] = stream.Length.ToString(CultureInfo.InvariantCulture); 677httpContext.Request.Headers["Content-Type"] = "application/json"; 681httpContext.Request.Headers["Content-Length"] = stream.Length.ToString(CultureInfo.InvariantCulture); 704httpContext.Request.Headers["Content-Type"] = "application/json"; 708httpContext.Request.Headers["Content-Length"] = stream.Length.ToString(CultureInfo.InvariantCulture); 731httpContext.Request.Headers["Content-Type"] = "application/json"; 735httpContext.Request.Headers["Content-Length"] = stream.Length.ToString(CultureInfo.InvariantCulture); 765httpContext.Request.Headers["Custom"] = new(new[] { "4", "5", "6" });
RequestDelegateGenerator\RequestDelegateCreationTests.AsParameters.cs (2)
96httpContext.Request.Headers[customHeaderName] = originalHeaderParam.ToString(NumberFormatInfo.InvariantInfo); 340httpContext.Request.Headers.Referer = uriValue;
RequestDelegateGenerator\RequestDelegateCreationTests.BindAsync.cs (10)
57httpContext.Request.Headers.Referer = "https://example.org"; 78httpContext.Request.Headers.Referer = "https://example.org"; 178httpContext.Request.Headers.Referer = "https://example.org"; 195httpContext.Request.Headers.Referer = "https://example.org"; 215httpContext.Request.Headers["Content-Type"] = "application/json"; 216httpContext.Request.Headers["Content-Length"] = stream.Length.ToString(CultureInfo.InvariantCulture); 233httpContext.Request.Headers.Referer = "https://example.org"; 271httpContext.Request.Headers["Content-Type"] = "application/json"; 272httpContext.Request.Headers["Content-Length"] = stream.Length.ToString(CultureInfo.InvariantCulture); 289httpContext.Request.Headers.Referer = "https://example.org";
RequestDelegateGenerator\RequestDelegateCreationTests.cs (7)
213httpContext.Request.Headers["headerValue"] = requestData; 436httpContext.Request.Headers.Referer = "https://example.org"; 462httpContext.Request.Headers.Referer = "https://example.org"; 509httpContext.Request.Headers.Referer = "https://example.org"; 534httpContext.Request.Headers.Referer = "https://example.org"; 559httpContext.Request.Headers.Referer = "https://example.org"; 589httpContext.Request.Headers["Custom"] = new(new[] { "4", "5", "6" });
RequestDelegateGenerator\RequestDelegateCreationTests.Filters.cs (1)
235httpContext.Request.Headers["Content-Type"] = "multipart/form-data;boundary=some-boundary";
RequestDelegateGenerator\RequestDelegateCreationTests.Forms.cs (30)
36httpContext.Request.Headers["Content-Type"] = "multipart/form-data;boundary=some-boundary"; 71httpContext.Request.Headers["Content-Type"] = "multipart/form-data;boundary=some-boundary"; 106httpContext.Request.Headers["Content-Type"] = "multipart/form-data;boundary=some-boundary"; 144httpContext.Request.Headers["Content-Type"] = "multipart/form-data;boundary=some-boundary"; 182httpContext.Request.Headers["Content-Type"] = "multipart/form-data;boundary=some-boundary"; 223httpContext.Request.Headers["Content-Type"] = "multipart/form-data;boundary=some-boundary"; 260httpContext.Request.Headers["Content-Type"] = "multipart/form-data;boundary=some-boundary"; 296httpContext.Request.Headers["Content-Type"] = "multipart/form-data;boundary=some-boundary"; 322httpContext.Request.Headers["Content-Type"] = "application/xml"; 323httpContext.Request.Headers["Content-Length"] = "1"; 370httpContext.Request.Headers["Content-Type"] = "multipart/form-data;boundary=some-boundary"; 403httpContext.Request.Headers["Content-Type"] = "multipart/form-data;boundary=some-boundary"; 452httpContext.Request.Headers[headerName] = headerValue; 453httpContext.Request.Headers["Content-Type"] = "multipart/form-data;boundary=some-boundary"; 492httpContext.Request.Headers["Content-Type"] = "multipart/form-data;boundary=some-boundary"; 551httpContext.Request.Headers["Content-Type"] = contentType; 598httpContext.Request.Headers["Content-Type"] = contentType; 645httpContext.Request.Headers["Content-Type"] = contentType; 674httpContext.Request.Headers["Content-Type"] = contentType; 707httpContext.Request.Headers["Content-Type"] = contentType; 737httpContext.Request.Headers["Content-Type"] = contentType; 767httpContext.Request.Headers["Content-Type"] = contentType; 830httpContext.Request.Headers["Content-Type"] = "multipart/form-data;boundary=some-boundary"; 874httpContext.Request.Headers["Content-Type"] = contentType; 930httpContext.Request.Headers["Content-Type"] = "application/x-www-form-urlencoded"; 931httpContext.Request.Headers["Content-Length"] = "1"; 962httpContext.Request.Headers["Content-Type"] = "application/x-www-form-urlencoded"; 963httpContext.Request.Headers["Content-Length"] = "2049"; 999httpContext.Request.Headers["Content-Type"] = "application/x-www-form-urlencoded"; 1000httpContext.Request.Headers["Content-Length"] = "2049";
RequestDelegateGenerator\RequestDelegateCreationTests.JsonBody.cs (12)
86httpContext.Request.Headers["Content-Type"] = "application/json"; 91httpContext.Request.Headers["Content-Length"] = stream.Length.ToString(CultureInfo.InvariantCulture); 106httpContext.Request.Headers["Content-Type"] = "application/json"; 107httpContext.Request.Headers["Content-Length"] = "0"; 234httpContext.Request.Headers["Content-Length"] = stream.Length.ToString(CultureInfo.InvariantCulture); 275httpContext.Request.Headers["Content-Length"] = stream.Length.ToString(CultureInfo.InvariantCulture); 319httpContext.Request.Headers["Content-Length"] = requestBodyBytes.Length.ToString(CultureInfo.InvariantCulture); 360httpContext.Request.Headers["Content-Length"] = requestBodyBytes.Length.ToString(CultureInfo.InvariantCulture); 398httpContext.Request.Headers["Content-Type"] = "application/json"; 399httpContext.Request.Headers["Content-Length"] = "0"; 427httpContext.Request.Headers["Content-Type"] = "application/json"; 432httpContext.Request.Headers["Content-Length"] = stream.Length.ToString(CultureInfo.InvariantCulture);
RequestDelegateGenerator\RequestDelegateCreationTests.JsonBodyOrService.cs (2)
198httpContext.Request.Headers["Content-Type"] = "application/json"; 199httpContext.Request.Headers["Content-Length"] = "0";
RequestDelegateGenerator\RequestDelegateCreationTests.Logging.cs (13)
384httpContext.Request.Headers["Content-Type"] = "application/xml"; 385httpContext.Request.Headers["Content-Length"] = "1"; 435httpContext.Request.Headers["Content-Type"] = "application/xml"; 481httpContext.Request.Headers["Content-Type"] = "application/json"; 482httpContext.Request.Headers["Content-Length"] = "1"; 517httpContext.Request.Headers["Content-Type"] = "application/json"; 518httpContext.Request.Headers["Content-Length"] = "1"; 558httpContext.Request.Headers["Content-Type"] = "application/json"; 559httpContext.Request.Headers["Content-Length"] = "1"; 597httpContext.Request.Headers["Content-Type"] = "application/json"; 598httpContext.Request.Headers["Content-Length"] = "1"; 637httpContext.Request.Headers["Content-Type"] = "application/json"; 638httpContext.Request.Headers["Content-Length"] = "1";
RequestDelegateGenerator\RuntimeCreationTests.ComplexFormBinding.cs (7)
31httpContext.Request.Headers["Content-Type"] = "application/x-www-form-urlencoded"; 67httpContext.Request.Headers["Content-Type"] = "multipart/form-data;boundary=some-boundary"; 99httpContext.Request.Headers["Content-Type"] = "application/x-www-form-urlencoded"; 136httpContext.Request.Headers["Content-Type"] = "multipart/form-data;boundary=some-boundary"; 173httpContext.Request.Headers["Content-Type"] = "multipart/form-data;boundary=some-boundary"; 208httpContext.Request.Headers["Content-Type"] = "application/x-www-form-urlencoded"; 245httpContext.Request.Headers["Content-Type"] = "multipart/form-data;boundary=some-boundary";
RequestDelegateGenerator\SharedTypes.cs (10)
226if (!Uri.TryCreate(context.Request.Headers.Referer, UriKind.Absolute, out var uri)) 253if (!Uri.TryCreate(context.Request.Headers.Referer, UriKind.Absolute, out var uri)) 278if (!Uri.TryCreate(context.Request.Headers.Referer, UriKind.Absolute, out var uri)) 305if (!Uri.TryCreate(context.Request.Headers.Referer, UriKind.Absolute, out var uri)) 322if (!Uri.TryCreate(context.Request.Headers.Referer, UriKind.Absolute, out var uri)) 338if (!Uri.TryCreate(context.Request.Headers.Referer, UriKind.Absolute, out var uri)) 359if (!Uri.TryCreate(context.Request.Headers.Referer, UriKind.Absolute, out var uri)) 392if (!Uri.TryCreate(context.Request.Headers.Referer, UriKind.Absolute, out var uri)) 426if (!Uri.TryCreate(context.Request.Headers.Referer, UriKind.Absolute, out var uri)) 450if (!Uri.TryCreate(context.Request.Headers.Referer, UriKind.Absolute, out var uri))
Microsoft.AspNetCore.Http.Microbenchmarks (12)
src\Http\Http.Extensions\test\RequestDelegateGenerator\RequestDelegateCreationTestBase.cs (2)
223httpContext.Request.Headers["Content-Type"] = "application/json"; 228httpContext.Request.Headers["Content-Length"] = stream.Length.ToString(CultureInfo.InvariantCulture);
src\Http\Http.Extensions\test\RequestDelegateGenerator\SharedTypes.cs (10)
226if (!Uri.TryCreate(context.Request.Headers.Referer, UriKind.Absolute, out var uri)) 253if (!Uri.TryCreate(context.Request.Headers.Referer, UriKind.Absolute, out var uri)) 278if (!Uri.TryCreate(context.Request.Headers.Referer, UriKind.Absolute, out var uri)) 305if (!Uri.TryCreate(context.Request.Headers.Referer, UriKind.Absolute, out var uri)) 322if (!Uri.TryCreate(context.Request.Headers.Referer, UriKind.Absolute, out var uri)) 338if (!Uri.TryCreate(context.Request.Headers.Referer, UriKind.Absolute, out var uri)) 359if (!Uri.TryCreate(context.Request.Headers.Referer, UriKind.Absolute, out var uri)) 392if (!Uri.TryCreate(context.Request.Headers.Referer, UriKind.Absolute, out var uri)) 426if (!Uri.TryCreate(context.Request.Headers.Referer, UriKind.Absolute, out var uri)) 450if (!Uri.TryCreate(context.Request.Headers.Referer, UriKind.Absolute, out var uri))
Microsoft.AspNetCore.Http.Results (1)
src\Shared\RangeHelper\RangeHelper.cs (1)
40var rawRangeHeader = context.Request.Headers.Range;
Microsoft.AspNetCore.Http.Results.Tests (16)
src\Shared\ResultsTests\FileContentResultTestBase.cs (4)
211httpContext.Request.Headers.Range = rangeString; 242httpContext.Request.Headers.Range = rangeString; 279httpContext.Request.Headers.Range = "bytes = 0-6"; 313httpContext.Request.Headers.Range = "bytes = 0-6";
src\Shared\ResultsTests\FileStreamResultTestBase.cs (4)
199httpContext.Request.Headers.Range = rangeString; 232httpContext.Request.Headers.Range = rangeString; 271httpContext.Request.Headers.Range = "bytes = 0-6"; 307httpContext.Request.Headers.Range = "bytes = 0-6";
src\Shared\ResultsTests\PhysicalFileResultTestBase.cs (4)
164httpContext.Request.Headers.Range = rangeString; 190httpContext.Request.Headers.Range = rangeString; 219httpContext.Request.Headers.Range = "bytes = 0-6"; 246httpContext.Request.Headers.Range = "bytes = 0-6";
src\Shared\ResultsTests\VirtualFileResultTestBase.cs (4)
198httpContext.Request.Headers.Range = rangeString; 231httpContext.Request.Headers.Range = rangeString; 269httpContext.Request.Headers.Range = "bytes = 0-6"; 300httpContext.Request.Headers.Range = "bytes = 0-6";
Microsoft.AspNetCore.Http.Tests (4)
Internal\DefaultHttpRequestTests.cs (4)
167var cookieHeaders = request.Headers["Cookie"]; 175request.Headers["Cookie"] = newCookies; 183Assert.Equal(newCookies, request.Headers["Cookie"].ToArray()); 192cookieHeaders = request.Headers["Cookie"];
Microsoft.AspNetCore.HttpLogging (8)
HttpLoggingFields.cs (1)
83/// Flag for logging the HTTP Request <see cref="HttpRequest.Headers"/>.
HttpLoggingMiddleware.cs (1)
140FilterHeaders(logContext, request.Headers, options._internalRequestHeaders);
W3CLoggingFields.cs (1)
136/// Flag for logging properties that are part of the <see cref="HttpRequest.Headers"/>
W3CLoggingMiddleware.cs (5)
146if (request.Headers.TryGetValue(HeaderNames.Host, out var host)) 154if (request.Headers.TryGetValue(HeaderNames.Referer, out var referer)) 162if (request.Headers.TryGetValue(HeaderNames.UserAgent, out var agent)) 172if (request.Headers.TryGetValue(HeaderNames.Cookie, out var cookie)) 184if (request.Headers.TryGetValue(additionalRequestHeaders[i], out var headerValue))
Microsoft.AspNetCore.HttpLogging.Tests (16)
HttpLoggingMiddlewareTests.cs (7)
260httpContext.Request.Headers["foo"] = "bar"; 278httpContext.Request.Headers["Connection"] = "keep-alive"; 280httpContext.Request.Headers["foo"] = "bar"; 1187httpContext.Request.Headers.Remove(HeaderNames.ContentType); 1252httpContext.Request.Headers.Connection = HeaderNames.Upgrade; 1253httpContext.Request.Headers.Upgrade = "websocket"; 1962httpContext.Request.Headers["Connection"] = "keep-alive";
W3CLoggingMiddlewareTests.cs (9)
59httpContext.Request.Headers["Referer"] = "bar"; 83httpContext.Request.Headers["Cookie"] = "Snickerdoodle"; 127httpContext.Request.Headers["Cookie"] = "Snickerdoodle"; 128httpContext.Request.Headers["x-forwarded-for"] = "1.3.3.7, 2001:db8:85a3:8d3:1319:8a2e:370:7348"; 169httpContext.Request.Headers["Cookie"] = "Snickerdoodle"; 200httpContext.Request.Headers["Cookie"] = "Snickerdoodle"; 201httpContext.Request.Headers["x-forwarded-for"] = "1.3.3.7, 2001:db8:85a3:8d3:1319:8a2e:370:7348"; 247httpContext.Request.Headers["Cookie"] = "Snickerdoodle"; 248httpContext.Request.Headers["x-forwarded-for"] = "1.3.3.7, 2001:db8:85a3:8d3:1319:8a2e:370:7348";
Microsoft.AspNetCore.HttpOverrides (3)
CertificateForwardingMiddleware.cs (1)
49var header = httpContext.Request.Headers[_options.CertificateHeader];
ForwardedHeadersMiddleware.cs (1)
128var requestHeaders = context.Request.Headers;
HttpMethodOverrideMiddleware.cs (1)
49var xHttpMethodOverrideValue = context.Request.Headers[xHttpMethodOverride];
Microsoft.AspNetCore.HttpOverrides.Tests (76)
CertificateForwardingTest.cs (5)
71c.Request.Headers["X-Client-Cert"] = Convert.ToBase64String(Certificates.SelfSignedValidWithNoEku.RawData); 110c.Request.Headers["X-Client-Cert"] = Convert.ToBase64String(Certificates.SelfSignedValidWithNoEku.RawData); 148c.Request.Headers["X-ARR-ClientCert"] = Convert.ToBase64String(Certificates.SelfSignedValidWithNoEku.RawData); 186c.Request.Headers["not-the-right-header"] = Convert.ToBase64String(Certificates.SelfSignedValidWithNoEku.RawData); 224c.Request.Headers["X-Client-Cert"] = "OOPS" + Convert.ToBase64String(Certificates.SelfSignedValidWithNoEku.RawData);
ForwardedHeadersMiddlewareTest.cs (71)
40c.Request.Headers["X-Forwarded-For"] = "11.111.111.11:9090"; 46Assert.False(context.Request.Headers.ContainsKey("X-Original-For")); 48Assert.False(context.Request.Headers.ContainsKey("X-Forwarded-For")); 76c.Request.Headers["X-Forwarded-For"] = header; 83Assert.False(context.Request.Headers.ContainsKey("X-Original-For")); 84Assert.True(context.Request.Headers.ContainsKey("X-Forwarded-For")); 85Assert.Equal(header, context.Request.Headers["X-Forwarded-For"]); 134c.Request.Headers["X-Forwarded-For"] = header; 141Assert.Equal(remainingHeader, context.Request.Headers["X-Forwarded-For"].ToString()); 172c.Request.Headers["X-Forwarded-For"] = "10.0.0.1:1234"; 181Assert.True(context.Request.Headers.ContainsKey("X-Original-For")); 183context.Request.Headers["X-Original-For"]); 189Assert.False(context.Request.Headers.ContainsKey("X-Original-For")); 245c.Request.Headers["X-Forwarded-For"] = header; 277c.Request.Headers["X-Forwarded-For"] = "BAD-IP"; 306c.Request.Headers["X-Forwarded-Host"] = "testhost"; 378c.Request.Headers["X-Forwarded-Host"] = hostHeader; 463c.Request.Headers["X-Forwarded-Host"] = hostHeader; 501Assert.Equal(hostHeader, context.Request.Headers.Host); 513ctx.Request.Headers["X-forwarded-Host"] = hostHeader; 552Assert.NotEqual<string>(hostHeader, context.Request.Headers.Host); 564ctx.Request.Headers["X-forwarded-Host"] = hostHeader; 588Assert.Equal("bar.foo.com:432", context.Request.Headers.Host); 600ctx.Request.Headers["X-forwarded-Host"] = "stuff:523, bar.foo.com:432, bar.com:80"; 636c.Request.Headers["X-Forwarded-Proto"] = header; 690c.Request.Headers["X-Forwarded-Proto"] = scheme; 747c.Request.Headers["X-Forwarded-Proto"] = scheme; 785c.Request.Headers["X-Forwarded-Proto"] = protoHeader; 786c.Request.Headers["X-Forwarded-For"] = forHeader; 827c.Request.Headers["X-Forwarded-Proto"] = protoHeader; 828c.Request.Headers["X-Forwarded-For"] = forHeader; 877c.Request.Headers["X-Forwarded-Proto"] = protoHeader; 878c.Request.Headers["X-Forwarded-For"] = forHeader; 918c.Request.Headers["X-Forwarded-Proto"] = "Protocol"; 919c.Request.Headers["X-Forwarded-For"] = "11.111.111.11"; 920c.Request.Headers["X-Forwarded-Host"] = "testhost"; 921c.Request.Headers["X-Forwarded-Prefix"] = "/pathbase"; 953c.Request.Headers["X-Forwarded-Proto"] = "Protocol"; 954c.Request.Headers["X-Forwarded-For"] = "11.111.111.11"; 955c.Request.Headers["X-Forwarded-Host"] = "otherhost"; 956c.Request.Headers["X-Forwarded-Prefix"] = "/pathbase"; 988c.Request.Headers["X-Forwarded-Proto"] = "Protocol"; 989c.Request.Headers["X-Forwarded-For"] = "11.111.111.11"; 1042c.Request.Headers["X-Forwarded-For"] = forHeader; 1081c.Request.Headers["X-Forwarded-Proto"] = header; 1085Assert.Equal(remainingHeader, context.Request.Headers["X-Forwarded-Proto"].ToString()); 1118c.Request.Headers["X-Forwarded-Proto"] = header; 1122Assert.Equal(remainingHeader, context.Request.Headers["X-Forwarded-Proto"].ToString()); 1157c.Request.Headers["X-Forwarded-Prefix"] = forwardedPrefix; 1162Assert.False(context.Request.Headers.ContainsKey("X-Original-Prefix")); 1164Assert.False(context.Request.Headers.ContainsKey("X-Forwarded-Prefix")); 1200c.Request.Headers["X-Forwarded-Prefix"] = forwardedPrefix; 1204Assert.Equal(expectedOriginalPrefix, context.Request.Headers["X-Original-Prefix"]); 1206Assert.False(context.Request.Headers.ContainsKey("X-Forwarded-Prefix")); 1235c.Request.Headers["X-Forwarded-Prefix"] = forwardedPrefix; 1239Assert.False(context.Request.Headers.ContainsKey("X-Original-Prefix")); 1240Assert.True(context.Request.Headers.ContainsKey("X-Forwarded-Prefix")); 1279c.Request.Headers["X-Forwarded-For"] = forwardedFor; 1280c.Request.Headers["X-Forwarded-Host"] = forwardedHost; 1281c.Request.Headers["X-Forwarded-Proto"] = forwardedProto; 1282c.Request.Headers["X-Forwarded-Prefix"] = forwardedPrefix; 1286Assert.False(context.Request.Headers.ContainsKey("X-Original-For")); 1287Assert.False(context.Request.Headers.ContainsKey("X-Original-Host")); 1288Assert.False(context.Request.Headers.ContainsKey("X-Original-Proto")); 1289Assert.False(context.Request.Headers.ContainsKey("X-Original-Prefix")); 1290Assert.True(context.Request.Headers.ContainsKey("X-Forwarded-For")); 1291Assert.True(context.Request.Headers.ContainsKey("X-Forwarded-Host")); 1292Assert.True(context.Request.Headers.ContainsKey("X-Forwarded-Proto")); 1293Assert.True(context.Request.Headers.ContainsKey("X-Forwarded-Prefix")); 1325c.Request.Headers["X-Forwarded-Prefix"] = forwardedPrefix; 1328Assert.Equal(expectedforwardedPrefix, context.Request.Headers["X-Forwarded-Prefix"].ToString());
Microsoft.AspNetCore.Mvc.Core (10)
Formatters\TextOutputFormatter.cs (1)
173if (StringWithQualityHeaderValue.TryParseList(request.Headers.AcceptCharset, out var result))
Infrastructure\DefaultOutputFormatterSelector.cs (1)
152AcceptHeaderParser.ParseAcceptHeader(request.Headers.Accept, result);
ModelBinding\Binders\HeaderModelBinder.cs (7)
63if (!request.Headers.ContainsKey(headerName)) 107if (request.Headers.TryGetValue(headerName, out var header)) 111values = request.Headers.GetCommaSeparatedValues(headerName); 130var value = request.Headers[headerName]; 135var values = request.Headers.GetCommaSeparatedValues(headerName); 156request.Headers.GetCommaSeparatedValues(headerName), 157request.Headers[headerName]);
src\Shared\RangeHelper\RangeHelper.cs (1)
40var rawRangeHeader = context.Request.Headers.Range;
Microsoft.AspNetCore.Mvc.Core.Test (53)
ActionConstraints\HttpMethodActionConstraintTest.cs (2)
76httpContext.Request.Headers.Add("Origin", StringValues.Empty); 77httpContext.Request.Headers.Add("Access-Control-Request-Method", accessControlMethod);
FileResultHelperTest.cs (2)
405httpContext.Request.Headers.IfModifiedSince = HeaderUtilities.FormatDate(ifModifiedSince); 443httpContext.Request.Headers.IfUnmodifiedSince = HeaderUtilities.FormatDate(ifUnmodifiedSince);
Formatters\JsonOutputFormatterTestBase.cs (1)
168httpContext.Request.Headers.AcceptCharset = contentType.Charset.ToString();
Formatters\TextOutputFormatterTests.cs (4)
43httpRequest.Headers.AcceptCharset = acceptCharsetHeaders; 44httpRequest.Headers.Accept = "application/acceptCharset"; 59ContentType = new StringSegment(httpRequest.Headers.Accept), 242context.Request.Headers.AcceptCharset = expectedValue;
Infrastructure\ActionSelectorTest.cs (1)
1109request.SetupGet(r => r.Headers).Returns(new HeaderDictionary());
Infrastructure\DefaultOutputFormatterSelectorTest.cs (8)
33context.HttpContext.Request.Headers.Accept = "application/xml"; // This will not be used 63context.HttpContext.Request.Headers.Accept = "application/xml"; // This will not be used 92context.HttpContext.Request.Headers.Accept = "application/xml"; // This will not be used 163context.HttpContext.Request.Headers.Accept = acceptHeader; 222context.HttpContext.Request.Headers.Accept = "text/custom,application/custom"; 257context.HttpContext.Request.Headers.Accept = "text/custom,application/custom"; 286context.HttpContext.Request.Headers.Accept = "text/custom"; 315context.HttpContext.Request.Headers.Accept = "text/custom, text/custom2";
Infrastructure\ObjectResultExecutorTest.cs (8)
26httpContext.Request.Headers.Accept = "application/xml"; // This will not be used 54httpContext.Request.Headers.Accept = "application/xml"; // This will not be used 77httpContext.Request.Headers.Accept = "application/xml"; // This will not be used 99httpContext.Request.Headers.Accept = "application/xml"; // This will not be used 189httpContext.Request.Headers.Accept = "application/json"; // This will not be used 215httpContext.Request.Headers.Accept = "application/xml"; // This will not be used 389actionContext.HttpContext.Request.Headers.Accept = acceptHeader; 426actionContext.HttpContext.Request.Headers.Accept = acceptHeader;
ModelBinding\Binders\HeaderModelBinderTests.cs (11)
28bindingContext.HttpContext.Request.Headers.Add(header, new[] { headerValue }); 50bindingContext.HttpContext.Request.Headers.Add(header, new[] { headerValue }); 77bindingContext.HttpContext.Request.Headers.Add(header, new[] { headerValue }); 96bindingContext.HttpContext.Request.Headers.Add("Header", new[] { headerValue }); 146bindingContext.HttpContext.Request.Headers.Add("Header", headerValue); 206bindingContext.HttpContext.Request.Headers.Add("Header", new[] { headerValue }); 223bindingContext.HttpContext.Request.Headers.Add("Header", "application/json,text/json"); 240bindingContext.HttpContext.Request.Headers.Add("Header", "application/json,text/json"); 264bindingContext.HttpContext.Request.Headers.Add("Header", "application/json,text/json"); 286bindingContext.HttpContext.Request.Headers.Add("Header", headerValue); 310bindingContext.HttpContext.Request.Headers.Add("Header", headerValue);
src\Shared\ResultsTests\FileContentResultTestBase.cs (4)
211httpContext.Request.Headers.Range = rangeString; 242httpContext.Request.Headers.Range = rangeString; 279httpContext.Request.Headers.Range = "bytes = 0-6"; 313httpContext.Request.Headers.Range = "bytes = 0-6";
src\Shared\ResultsTests\FileStreamResultTestBase.cs (4)
199httpContext.Request.Headers.Range = rangeString; 232httpContext.Request.Headers.Range = rangeString; 271httpContext.Request.Headers.Range = "bytes = 0-6"; 307httpContext.Request.Headers.Range = "bytes = 0-6";
src\Shared\ResultsTests\PhysicalFileResultTestBase.cs (4)
164httpContext.Request.Headers.Range = rangeString; 190httpContext.Request.Headers.Range = rangeString; 219httpContext.Request.Headers.Range = "bytes = 0-6"; 246httpContext.Request.Headers.Range = "bytes = 0-6";
src\Shared\ResultsTests\VirtualFileResultTestBase.cs (4)
198httpContext.Request.Headers.Range = rangeString; 231httpContext.Request.Headers.Range = rangeString; 269httpContext.Request.Headers.Range = "bytes = 0-6"; 300httpContext.Request.Headers.Range = "bytes = 0-6";
Microsoft.AspNetCore.Mvc.Cors (5)
CorsAuthorizationFilter.cs (2)
76if (request.Headers.ContainsKey(CorsConstants.Origin)) 90httpContext.Request.Headers[CorsConstants.AccessControlRequestMethod];
CorsHttpMethodActionConstraint.cs (2)
33request.Headers.ContainsKey(OriginHeader) && 34request.Headers.TryGetValue(AccessControlRequestMethod, out var accessControlRequestMethod) &&
DisableCorsAuthorizationFilter.cs (1)
27context.HttpContext.Request.Headers[CorsConstants.AccessControlRequestMethod];
Microsoft.AspNetCore.Mvc.Cors.Test (11)
CorsAuthorizationFilterTest.cs (4)
138httpContext.Request.Headers.Add(CorsConstants.AccessControlRequestHeaders, headers.Headers.Split(',')); 139httpContext.Request.Headers.Add(CorsConstants.AccessControlRequestMethod, new[] { headers.Method }); 140httpContext.Request.Headers.Add(CorsConstants.AccessControlExposeHeaders, headers.ExposedHeaders.Split(',')); 141httpContext.Request.Headers.Add(CorsConstants.Origin, new[] { headers.Origin });
CorsHttpMethodActionConstraintTest.cs (2)
92httpContext.Request.Headers.Add("Origin", StringValues.Empty); 95httpContext.Request.Headers.Add("Access-Control-Request-Method", accessControlMethod);
DisableCorsAuthorizationFilterTest.cs (5)
21httpContext.Request.Headers.Add(CorsConstants.Origin, "http://localhost:5000/"); 22httpContext.Request.Headers.Add(CorsConstants.AccessControlRequestMethod, "PUT"); 41httpContext.Request.Headers.Add(CorsConstants.Origin, "http://localhost:5000/"); 62httpContext.Request.Headers.Add(CorsConstants.Origin, "http://localhost:5000/"); 63httpContext.Request.Headers.Add(CorsConstants.AccessControlRequestMethod, "PUT");
Microsoft.AspNetCore.Mvc.Formatters.Xml.Test (4)
XmlDataContractSerializerInputFormatterTest.cs (1)
740request.SetupGet(r => r.Headers).Returns(headers.Object);
XmlDataContractSerializerOutputFormatterTest.cs (1)
804request.Headers["Accept-Charset"] = MediaTypeHeaderValue.Parse(contentType).Charset.ToString();
XmlSerializerInputFormatterTest.cs (1)
676request.SetupGet(r => r.Headers).Returns(headers.Object);
XmlSerializerOutputFormatterTest.cs (1)
586request.Headers["Accept-Charset"] = MediaTypeHeaderValue.Parse(contentType).Charset.ToString();
Microsoft.AspNetCore.Mvc.IntegrationTests (25)
BindingSourceMetadataProviderIntegrationTest.cs (2)
136request.Headers["Content-Disposition"] = $"form-data; name={name}; filename={fileName}"; 141Headers = request.Headers
ComplexRecordIntegrationTest.cs (3)
2911request.Headers.Add("GpsCoordinates", "10,20"); 3727request.Headers.Add("Id", "not-bound"); 3770request.Headers.Add("Id", "not-bound");
ComplexTypeIntegrationTestBase.cs (1)
3115request.Headers.Add("GpsCoordinates", "10,20");
FormCollectionModelBindingIntegrationTest.cs (2)
165request.Headers["Content-Disposition"] = $"form-data; name={name}; filename={fileName}"; 168Headers = request.Headers
FormFileModelBindingIntegrationTest.cs (2)
1270request.Headers["Content-Disposition"] = $"form-data; name={name}; filename={fileName}"; 1276Headers = request.Headers
HeaderModelBinderIntegrationTest.cs (13)
81request => request.Headers.Add("Header", new[] { "someValue" })); 123request => request.Headers.Add("Header", new[] { "someValue" })); 169request => request.Headers.Add("Header", new[] { "someValue" })); 216request => request.Headers.Add("Header", new[] { "someValue" })); 275void action(HttpRequest r) => r.Headers.Add("CustomParameter", new[] { expectedAttemptedValue }); 322request.Headers.Add("NoCommaString", "someValue"); 323request.Headers.Add("OneCommaSeparatedString", "one, two, three"); 324request.Headers.Add("IntProperty", "10"); 325request.Headers.Add("NullableIntProperty", "300"); 326request.Headers.Add("ArrayOfString", "first, second"); 327request.Headers.Add("EnumerableOfDouble", "10.51, 45.44"); 328request.Headers.Add("ListOfEnum", "Sedan, Coupe"); 329request.Headers.Add("ListOfOrderWithTypeConverter", "10");
TryUpdateModelIntegrationTest.cs (2)
1282request.Headers["Content-Disposition"] = $"form-data; name={name}; filename={fileName}"; 1287Headers = request.Headers
Microsoft.AspNetCore.Mvc.NewtonsoftJson.Test (2)
NewtonsoftJsonPatchInputFormatterTest.cs (1)
260request.SetupGet(r => r.Headers).Returns(headers.Object);
src\Mvc\Mvc.Core\test\Formatters\JsonOutputFormatterTestBase.cs (1)
168httpContext.Request.Headers.AcceptCharset = contentType.Charset.ToString();
Microsoft.AspNetCore.Mvc.TagHelpers (1)
Cache\CacheTagKey.cs (1)
89_headers = ExtractCollection(tagHelper.VaryByHeader, request.Headers, HeaderAccessor);
Microsoft.AspNetCore.Mvc.TagHelpers.Test (8)
CacheTagHelperTest.cs (2)
156cacheTagHelper1.ViewContext.HttpContext.Request.Headers["Cookie"] = "cookie1=value1;cookie2=value2"; 178cacheTagHelper2.ViewContext.HttpContext.Request.Headers["Cookie"] = "cookie1=value1;cookie2=not-value2";
CacheTagKeyTest.cs (4)
211cacheTagHelper.ViewContext.HttpContext.Request.Headers["Cookie"] = 237var headers = cacheTagHelper.ViewContext.HttpContext.Request.Headers; 404cacheTagHelper.ViewContext.HttpContext.Request.Headers["Content-Type"] = "text/html"; 431cacheTagHelper.ViewContext.HttpContext.Request.Headers["Content-Type"] = "text/html";
DistributedCacheTagHelperTest.cs (2)
208cacheTagHelper1.ViewContext.HttpContext.Request.Headers["Cookie"] = "cookie1=value1;cookie2=value2"; 232cacheTagHelper2.ViewContext.HttpContext.Request.Headers["Cookie"] = "cookie1=value1;cookie2=not-value2";
Microsoft.AspNetCore.Mvc.ViewFeatures.Test (4)
CookieTempDataProviderTest.cs (4)
82context.Request.Headers.Cookie = $"{CookieTempDataProvider.CookieName}={base64AndUrlEncodedDataInCookie}"; 104httpContext.Request.Headers.Cookie = $"{CookieTempDataProvider.CookieName}={base64AndUrlEncodedDataInCookie}"; 277httpContext.Request.Headers.Cookie = requestCookies; 335httpContext.Request.Headers.Cookie = stringBuilder.ToString();
Microsoft.AspNetCore.OutputCaching.Tests (34)
OutputCacheAttributeTests.cs (2)
78context.HttpContext.Request.Headers["HeaderA"] = "ValueA"; 79context.HttpContext.Request.Headers["HeaderB"] = "ValueB";
OutputCacheKeyProviderTests.cs (11)
145context.HttpContext.Request.Headers["HeaderA"] = "ValueA"; 146context.HttpContext.Request.Headers["HeaderB"] = "ValueB"; 158context.HttpContext.Request.Headers["HeaderA"] = "ValueA"; 170context.HttpContext.Request.Headers["HeaderA"] = "ValueB"; 171context.HttpContext.Request.Headers.Append("HeaderA", "ValueA"); 267context.HttpContext.Request.Headers["HeaderA"] = "ValueA"; 268context.HttpContext.Request.Headers["HeaderB"] = "ValueB"; 323context.HttpContext.Request.Headers["HeaderA"] = "ValueA" + KeyDelimiter; 324context.HttpContext.Request.Headers["HeaderB"] = "ValueB"; 337context.HttpContext.Request.Headers["HeaderA"] = "ValueA"; 338context.HttpContext.Request.Headers["HeaderB"] = "ValueB" + KeyDelimiter;
OutputCacheMiddlewareTests.cs (14)
39context.HttpContext.Request.Headers.CacheControl = new CacheControlHeaderValue() 133context.HttpContext.Request.Headers.IfNoneMatch = "*"; 179context.HttpContext.Request.Headers.IfModifiedSince = HeaderUtilities.FormatDate(utcNow); 217context.HttpContext.Request.Headers.IfModifiedSince = HeaderUtilities.FormatDate(utcNow); 260context.HttpContext.Request.Headers.IfModifiedSince = HeaderUtilities.FormatDate(utcNow); 263context.HttpContext.Request.Headers.IfNoneMatch = EntityTagHeaderValue.Any.ToString(); 281context.HttpContext.Request.Headers.IfModifiedSince = HeaderUtilities.FormatDate(utcNow); 284context.HttpContext.Request.Headers.IfNoneMatch = "\"E1\""; 297context.HttpContext.Request.Headers.IfNoneMatch = "\"E1\""; 327context.HttpContext.Request.Headers.IfNoneMatch = requestETag.ToString(); 344context.HttpContext.Request.Headers.IfNoneMatch = "\"E1\""; 359context.HttpContext.Request.Headers.IfNoneMatch = new string[] { "\"E0\", \"E1\"", "\"E1\", \"E2\"" }; 995context.AllowCacheLookup = !context.HttpContext.Request.Headers.ContainsKey("X-Refresh"); 1050requestContext.HttpContext.Request.Headers.Add("X-Refresh", "randomvalue");
OutputCachePolicyBuilderTests.cs (2)
107context.HttpContext.Request.Headers["HeaderA"] = "ValueA"; 108context.HttpContext.Request.Headers["HeaderB"] = "ValueB";
OutputCachePolicyProviderTests.cs (4)
82context.HttpContext.Request.Headers.Authorization = "Placeholder"; 98context.HttpContext.Request.Headers.CacheControl = new CacheControlHeaderValue() 116context.HttpContext.Request.Headers.Pragma = "no-cache"; 117context.HttpContext.Request.Headers.CacheControl = "max-age=10";
OutputCacheTests.cs (1)
889var builders = TestUtils.CreateBuildersWithOutputCaching(contextAction: context => context.Response.Headers.Vary = context.Request.Headers.Pragma);
Microsoft.AspNetCore.Owin.Tests (2)
OwinEnvironmentTests.cs (2)
25context.Request.Headers["CustomRequestHeader"] = "CustomRequestValue"; 86Assert.Equal("CustomRequestValue", context.Request.Headers["CustomRequestHeader"]);
Microsoft.AspNetCore.RequestDecompression (2)
DefaultRequestDecompressionProvider.cs (2)
32var encodings = context.Request.Headers.ContentEncoding; 52context.Request.Headers.Remove(HeaderNames.ContentEncoding);
Microsoft.AspNetCore.RequestDecompression.Microbenchmarks (1)
RequestDecompressionMiddlewareBenchmark.cs (1)
40context.Request.Headers.ContentEncoding = "gzip";
Microsoft.AspNetCore.RequestDecompression.Tests (8)
DefaultRequestDecompressionProviderTests.cs (7)
29httpContext.Request.Headers.Add(HeaderNames.ContentEncoding, contentEncoding); 47var contentEncodingHeader = httpContext.Request.Headers.ContentEncoding; 72var contentEncodingHeader = httpContext.Request.Headers.ContentEncoding; 82httpContext.Request.Headers.Add(HeaderNames.ContentEncoding, contentEncoding); 99var contentEncodingHeader = httpContext.Request.Headers.ContentEncoding; 110httpContext.Request.Headers.Add(HeaderNames.ContentEncoding, contentEncodings); 127var contentEncodingHeader = httpContext.Request.Headers.ContentEncoding;
RequestDecompressionMiddlewareTests.cs (1)
296contentEncodingHeader = context.Request.Headers.ContentEncoding;
Microsoft.AspNetCore.ResponseCaching (8)
ResponseCachingKeyProvider.cs (1)
106var requestHeaders = context.HttpContext.Request.Headers;
ResponseCachingMiddleware.cs (3)
230if (HeaderUtilities.ContainsCacheDirective(context.HttpContext.Request.Headers.CacheControl, CacheControlHeaderValue.OnlyIfCachedString)) 431var ifNoneMatchHeader = context.HttpContext.Request.Headers.IfNoneMatch; 459var ifModifiedSince = context.HttpContext.Request.Headers.IfModifiedSince;
ResponseCachingPolicyProvider.cs (4)
24if (!StringValues.IsNullOrEmpty(request.Headers.Authorization)) 35var requestHeaders = context.HttpContext.Request.Headers; 63return !HeaderUtilities.ContainsCacheDirective(context.HttpContext.Request.Headers.CacheControl, CacheControlHeaderValue.NoStoreString); 170var requestCacheControlHeaders = context.HttpContext.Request.Headers.CacheControl;
Microsoft.AspNetCore.ResponseCaching.Microbenchmarks (1)
ResponseCachingBenchmark.cs (1)
61context.Request.Headers.CacheControl = CacheControlHeaderValue.NoCacheString;
Microsoft.AspNetCore.ResponseCaching.Tests (2)
ResponseCachingTests.cs (2)
848var builders = TestUtils.CreateBuildersWithResponseCaching(contextAction: context => context.Response.Headers.Vary = context.Request.Headers.Pragma); 883var builders = TestUtils.CreateBuildersWithResponseCaching(contextAction: context => context.Response.Headers.Vary = context.Request.Headers.Pragma);
Microsoft.AspNetCore.ResponseCompression (2)
ResponseCompressionProvider.cs (2)
78var accept = context.Request.Headers.AcceptEncoding; 221if (string.IsNullOrEmpty(context.Request.Headers.AcceptEncoding))
Microsoft.AspNetCore.ResponseCompression.Microbenchmarks (1)
ResponseCompressionProviderBenchmark.cs (1)
51context.Request.Headers.AcceptEncoding = AcceptEncoding;
Microsoft.AspNetCore.Rewrite (1)
PatternSegments\HeaderSegment.cs (1)
17return context.HttpContext.Request.Headers[_header];
Microsoft.AspNetCore.Rewrite.Tests (6)
IISUrlRewrite\ServerVariableTests.cs (5)
145context.Request.Headers.Accept = "accept"; 146context.Request.Headers.Cookie = "cookie"; 147context.Request.Headers.Referer = "referer"; 148context.Request.Headers.UserAgent = "useragent"; 149context.Request.Headers.Connection = "connection";
PatternSegments\HeaderSegmentTests.cs (1)
18context.HttpContext.Request.Headers.Location = "foo";
Microsoft.AspNetCore.Routing (4)
Matching\ContentEncodingNegotiationMatcherPolicy.cs (1)
17private protected override StringValues GetNegotiationHeader(HttpContext httpContext) => httpContext.Request.Headers[HeaderName];
Matching\HttpMethodMatcherPolicy.cs (2)
116var headers = httpContext.Request.Headers; 422var headers = httpContext.Request.Headers;
Matching\NegotiationMatcherPolicy.cs (1)
402var header = httpContext.Request.Headers[_negotiationHeader];
Microsoft.AspNetCore.Routing.Tests (24)
Matching\ContentEncodingNegotiationMatcherPolicyTest.cs (22)
80httpContext.Request.Headers["Accept-Encoding"] = "gzip, br"; 100httpContext.Request.Headers["Accept-Encoding"] = "br"; 120httpContext.Request.Headers["Accept-Encoding"] = "br"; 140httpContext.Request.Headers["Accept-Encoding"] = "gzip;q=0.5, br;q=1.0"; 160httpContext.Request.Headers["Accept-Encoding"] = "gzip;q=0.5, br;q=1.0"; 180httpContext.Request.Headers["Accept-Encoding"] = "gzip, br"; 199httpContext.Request.Headers["Accept-Encoding"] = "zstd"; 220httpContext.Request.Headers["Accept-Encoding"] = "zstd"; 241httpContext.Request.Headers["Accept-Encoding"] = "gzip, br"; 260httpContext.Request.Headers["Accept-Encoding"] = "br, gzip"; 279httpContext.Request.Headers["Accept-Encoding"] = "identity"; 298httpContext.Request.Headers["Accept-Encoding"] = "identity"; 317httpContext.Request.Headers["Accept-Encoding"] = ""; 449httpContext.Request.Headers["Accept-Encoding"] = "gzip, br"; 467httpContext.Request.Headers["Accept-Encoding"] = "br"; 485httpContext.Request.Headers["Accept-Encoding"] = "br"; 503httpContext.Request.Headers["Accept-Encoding"] = "gzip;q=0.5, br;q=1.0"; 521httpContext.Request.Headers["Accept-Encoding"] = "gzip;q=0.5, br;q=1.0"; 539httpContext.Request.Headers["Accept-Encoding"] = "gzip, br"; 557httpContext.Request.Headers["Accept-Encoding"] = "identity"; 575httpContext.Request.Headers["Accept-Encoding"] = "identity"; 593httpContext.Request.Headers["Accept-Encoding"] = "";
Matching\HttpMethodMatcherPolicyIntegrationTestBase.cs (2)
374httpContext.Request.Headers[HeaderNames.Origin] = "example.com"; 375httpContext.Request.Headers[HeaderNames.AccessControlRequestMethod] = httpMethod;
Microsoft.AspNetCore.Security.Microbenchmarks (1)
ChunkingCookieManagerBenchmark.cs (1)
36_httpContext.Request.Headers["Cookie"] = new[]
Microsoft.AspNetCore.Server.HttpSys.FunctionalTests (21)
Http2Tests.cs (3)
121Assert.False(httpContext.Request.Headers.ContainsKey(HeaderNames.TransferEncoding)); 171Assert.False(httpContext.Request.Headers.ContainsKey(HeaderNames.TransferEncoding)); 236Assert.Equal("chunked", httpContext.Request.Headers.TransferEncoding);
RequestBodyTests.cs (10)
219foreach (var header in httpContext.Request.Headers) 247foreach (var header in request.Headers) 261httpContext.Request.Headers[HeaderNames.ContentLength] = "123"; 264httpContext.Request.Headers[HeaderNames.ContentLength] = "456"; 267httpContext.Request.Headers[HeaderNames.ContentLength] = StringValues.Empty; 270Assert.Equal("", httpContext.Request.Headers[HeaderNames.ContentLength].ToString()); 276httpContext.Request.Headers["Custom-Header"] = "foo"; 278httpContext.Request.Headers["Custom-Header"] = "bar"; 280httpContext.Request.Headers["Custom-Header"] = StringValues.Empty; 282Assert.Equal("", httpContext.Request.Headers["Custom-Header"].ToString());
RequestHeaderTests.cs (8)
24var requestHeaders = httpContext.Request.Headers; 43var requestHeaders = httpContext.Request.Headers; 89var requestHeaders = httpContext.Request.Headers; 108var requestHeaders = httpContext.Request.Headers; 131var requestHeaders = httpContext.Request.Headers; 154var requestHeaders = httpContext.Request.Headers; 186var requestHeaders = httpContext.Request.Headers; 213var requestHeaders = httpContext.Request.Headers;
Microsoft.AspNetCore.Server.IISIntegration (4)
IISMiddleware.cs (4)
103if (!string.Equals(_pairingToken, httpContext.Request.Headers[MSAspNetCoreToken], StringComparison.Ordinal)) 113string.Equals(ANCMShutdownEventHeaderValue, httpContext.Request.Headers[MSAspNetCoreEvent], StringComparison.OrdinalIgnoreCase)) 137var header = httpContext.Request.Headers[MSAspNetCoreClientCert]; 172var tokenHeader = context.Request.Headers[MSAspNetCoreWinAuthToken];
Microsoft.AspNetCore.SignalR.Client.FunctionalTests (2)
HeaderUserIdProvider.cs (1)
13return connection.GetHttpContext()?.Request?.Headers?[HeaderName];
Hubs.cs (1)
66var headers = context.Request.Headers;
Microsoft.AspNetCore.SignalR.StackExchangeRedis.Tests (1)
Startup.cs (1)
44var userNameHeader = connection.GetHttpContext().Request.Headers["UserName"];
Microsoft.AspNetCore.SignalR.Tests (2)
HttpHeaderConnectionHandler.cs (1)
23var headers = connection.Features.Get<IHttpContextFeature>().HttpContext.Request.Headers;
Startup.cs (1)
59(context.HttpContext.WebSockets.IsWebSocketRequest || context.Request.Headers["Accept"] == "text/event-stream"))
Microsoft.AspNetCore.SpaServices.Extensions (2)
Proxying\SpaProxy.cs (2)
145foreach (var header in request.Headers) 220foreach (var headerEntry in context.Request.Headers)
Microsoft.AspNetCore.StaticAssets (1)
src\Shared\RangeHelper\RangeHelper.cs (1)
40var rawRangeHeader = context.Request.Headers.Range;
Microsoft.AspNetCore.StaticFiles (1)
src\Shared\RangeHelper\RangeHelper.cs (1)
40var rawRangeHeader = context.Request.Headers.Range;
Microsoft.AspNetCore.StaticFiles.FunctionalTests (1)
src\Shared\RangeHelper\RangeHelper.cs (1)
40var rawRangeHeader = context.Request.Headers.Range;
Microsoft.AspNetCore.StaticFiles.Tests (3)
RangeHelperTests.cs (3)
65httpContext.Request.Headers.Range = range; 82httpContext.Request.Headers.Range = range; 98httpContext.Request.Headers.Range = range.ToString();
Microsoft.AspNetCore.TestHost (8)
ClientHandler.cs (3)
147req.Headers.Append(header.Key, header.Value.ToArray()); 162req.Headers.Append(header.Key, string.Join(' ', header.Value)); 166req.Headers.Append(header.Key, header.Value.ToArray());
WebSocketClient.cs (5)
79request.Headers.Add(HeaderNames.Connection, new string[] { "Upgrade" }); 80request.Headers.Add(HeaderNames.Upgrade, new string[] { "websocket" }); 81request.Headers.Add(HeaderNames.SecWebSocketVersion, new string[] { "13" }); 82request.Headers.Add(HeaderNames.SecWebSocketKey, new string[] { CreateRequestKey() }); 85request.Headers.Add(HeaderNames.SecWebSocketProtocol, SubProtocols.ToArray());
Microsoft.AspNetCore.TestHost.Tests (11)
ClientHandlerTests.cs (6)
57Assert.NotNull(context.Request.Headers); 115var actualResult = context.Request.Headers.UserAgent; 134Assert.False(context.Request.Headers.ContainsKey(HeaderNames.TransferEncoding)); 151Assert.False(context.Request.Headers.ContainsKey(HeaderNames.TransferEncoding)); 167Assert.Equal("chunked", context.Request.Headers.TransferEncoding); 184Assert.Equal("chunked", context.Request.Headers.TransferEncoding);
HttpContextBuilderTests.cs (3)
40Assert.NotNull(context.Request.Headers); 56c.Request.Headers.UserAgent = userAgent; 59var actualResult = context.Request.Headers.UserAgent;
TestClientTests.cs (1)
582Assert.False(ctx.Request.Headers.ContainsKey(HeaderNames.SecWebSocketProtocol));
TestServerTests.cs (1)
784ctx.Response.WriteAsync(ctx.Request.Headers.Host);
Microsoft.AspNetCore.WebSockets (6)
WebSocketMiddleware.cs (6)
68var originHeader = context.Request.Headers.Origin; 116_isH2WebSocket = CheckSupportedWebSocketRequestH2(_context.Request.Method, _connectFeature.Protocol, _context.Request.Headers); 121_isWebSocketRequest = CheckSupportedWebSocketRequest(_context.Request.Method, _context.Request.Headers); 165HandshakeHelpers.GenerateResponseHeaders(!_isH2WebSocket, _context.Request.Headers, subProtocol, _context.Response.Headers); 170var ext = _context.Request.Headers.SecWebSocketExtensions; 174foreach (var extension in _context.Request.Headers.GetCommaSeparatedValues(HeaderNames.SecWebSocketExtensions))
Microsoft.AspNetCore.WebSockets.Tests (8)
Http2WebSocketTests.cs (2)
45httpContext.Request.Headers.SecWebSocketVersion = Constants.Headers.SupportedVersion; 46httpContext.Request.Headers.SecWebSocketProtocol = "p1, p2";
WebSocketMiddlewareTests.cs (6)
40Assert.Equal("alpha, bravo, charlie", context.Request.Headers["Sec-WebSocket-Protocol"]); 728Assert.Same(HeaderNames.Upgrade, context.Request.Headers.Connection.ToString()); 729Assert.Same(Constants.Headers.UpgradeWebSocket, context.Request.Headers.Upgrade.ToString()); 730Assert.Same(Constants.Headers.SupportedVersion, context.Request.Headers.SecWebSocketVersion.ToString()); 748Assert.Equal("Upgrade, keep-alive", context.Request.Headers.Connection.ToString()); 749Assert.Equal("websocket, example", context.Request.Headers.Upgrade.ToString());
NativeIISSample (2)
Startup.cs (2)
41await context.Response.WriteAsync("Host: " + context.Request.Headers["Host"] + Environment.NewLine); 65foreach (var header in context.Request.Headers)
OpenIdConnectSample (1)
Startup.cs (1)
34var userAgent = httpContext.Request.Headers["User-Agent"].ToString();
SignalR.Client.FunctionalTestApp (6)
Startup.cs (4)
77string token = request.Headers["Authorization"]; 122var originHeader = context.Request.Headers.Origin; 129var requestMethod = context.Request.Headers.AccessControlRequestMethod; 135var requestHeaders = context.Request.Headers.AccessControlRequestHeaders;
TestHub.cs (2)
134return Context.GetHttpContext().Request.Headers["Content-Type"]; 139return Context.GetHttpContext().Request.Headers[headerName];
StatusCodePagesSample (1)
Startup.cs (1)
68var referrer = context.Request.Headers["referer"];
WebPubSubWeb (2)
Program.cs (2)
61if (context.Request.Method != "POST" || !context.Request.Headers.TryGetValue("ce-type", out var eventType)) 67var userId = context.Request.Headers["ce-userId"];