diff --git a/src/Antiforgery/src/Internal/DefaultAntiforgery.cs b/src/Antiforgery/src/Internal/DefaultAntiforgery.cs index 8259fd540ddf..030f79c07efc 100644 --- a/src/Antiforgery/src/Internal/DefaultAntiforgery.cs +++ b/src/Antiforgery/src/Internal/DefaultAntiforgery.cs @@ -263,12 +263,12 @@ private void SaveCookieTokenAndHeader(HttpContext httpContext, string cookieToke _tokenStore.SaveCookieToken(httpContext, cookieToken); } - if (!_options.SuppressXFrameOptionsHeader && !httpContext.Response.Headers.ContainsKey("X-Frame-Options")) + if (!_options.SuppressXFrameOptionsHeader && !httpContext.Response.Headers.ContainsKey(HeaderNames.XFrameOptions)) { // Adding X-Frame-Options header to prevent ClickJacking. See // http://tools.ietf.org/html/draft-ietf-websec-x-frame-options-10 // for more information. - httpContext.Response.Headers["X-Frame-Options"] = "SAMEORIGIN"; + httpContext.Response.Headers[HeaderNames.XFrameOptions] = "SAMEORIGIN"; } } diff --git a/src/Hosting/Hosting/src/GenericHost/GenericWebHostedService.cs b/src/Hosting/Hosting/src/GenericHost/GenericWebHostedService.cs index 816f70deb9e7..4d6ccf6fb007 100644 --- a/src/Hosting/Hosting/src/GenericHost/GenericWebHostedService.cs +++ b/src/Hosting/Hosting/src/GenericHost/GenericWebHostedService.cs @@ -20,6 +20,7 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Microsoft.Extensions.StackTrace.Sources; +using Microsoft.Net.Http.Headers; namespace Microsoft.AspNetCore.Hosting.Internal { @@ -184,7 +185,7 @@ private RequestDelegate BuildErrorPageApplication(Exception exception) return context => { context.Response.StatusCode = 500; - context.Response.Headers["Cache-Control"] = "no-cache"; + context.Response.Headers[HeaderNames.CacheControl] = "no-cache"; return errorPage.ExecuteAsync(context); }; } diff --git a/src/Hosting/Hosting/src/Internal/HostingApplicationDiagnostics.cs b/src/Hosting/Hosting/src/Internal/HostingApplicationDiagnostics.cs index 44802f651ecf..84653599ee7c 100644 --- a/src/Hosting/Hosting/src/Internal/HostingApplicationDiagnostics.cs +++ b/src/Hosting/Hosting/src/Internal/HostingApplicationDiagnostics.cs @@ -22,11 +22,6 @@ internal class HostingApplicationDiagnostics private const string DeprecatedDiagnosticsEndRequestKey = "Microsoft.AspNetCore.Hosting.EndRequest"; private const string DiagnosticsUnhandledExceptionKey = "Microsoft.AspNetCore.Hosting.UnhandledException"; - private const string RequestIdHeaderName = "Request-Id"; - private const string CorrelationContextHeaderName = "Correlation-Context"; - private const string TraceParentHeaderName = "traceparent"; - private const string TraceStateHeaderName = "tracestate"; - private readonly DiagnosticListener _diagnosticListener; private readonly ILogger _logger; @@ -238,22 +233,22 @@ private Activity StartActivity(HttpContext httpContext) { var activity = new Activity(ActivityName); - if (!httpContext.Request.Headers.TryGetValue(TraceParentHeaderName, out var requestId)) + if (!httpContext.Request.Headers.TryGetValue(HeaderNames.TraceParent, out var requestId)) { - httpContext.Request.Headers.TryGetValue(RequestIdHeaderName, out requestId); + httpContext.Request.Headers.TryGetValue(HeaderNames.RequestId, out requestId); } if (!StringValues.IsNullOrEmpty(requestId)) { activity.SetParentId(requestId); - if (httpContext.Request.Headers.TryGetValue(TraceStateHeaderName, out var traceState)) + if (httpContext.Request.Headers.TryGetValue(HeaderNames.TraceState, out var traceState)) { activity.TraceStateString = traceState; } // We expect baggage to be empty by default // Only very advanced users will be using it in near future, we encourage them to keep baggage small (few items) - string[] baggage = httpContext.Request.Headers.GetCommaSeparatedValues(CorrelationContextHeaderName); + string[] baggage = httpContext.Request.Headers.GetCommaSeparatedValues(HeaderNames.CorrelationContext); if (baggage.Length > 0) { foreach (var item in baggage) diff --git a/src/Hosting/Hosting/src/Internal/WebHost.cs b/src/Hosting/Hosting/src/Internal/WebHost.cs index 8dcfa065150c..1aa779ee3719 100644 --- a/src/Hosting/Hosting/src/Internal/WebHost.cs +++ b/src/Hosting/Hosting/src/Internal/WebHost.cs @@ -22,6 +22,7 @@ using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.Extensions.StackTrace.Sources; +using Microsoft.Net.Http.Headers; namespace Microsoft.AspNetCore.Hosting.Internal { @@ -276,7 +277,7 @@ private RequestDelegate BuildApplication() return context => { context.Response.StatusCode = 500; - context.Response.Headers["Cache-Control"] = "no-cache"; + context.Response.Headers[HeaderNames.CacheControl] = "no-cache"; return errorPage.ExecuteAsync(context); }; } diff --git a/src/Http/Headers/ref/Microsoft.Net.Http.Headers.netcoreapp3.0.cs b/src/Http/Headers/ref/Microsoft.Net.Http.Headers.netcoreapp3.0.cs index e2b93d100332..838497b88fcf 100644 --- a/src/Http/Headers/ref/Microsoft.Net.Http.Headers.netcoreapp3.0.cs +++ b/src/Http/Headers/ref/Microsoft.Net.Http.Headers.netcoreapp3.0.cs @@ -118,74 +118,87 @@ public EntityTagHeaderValue(Microsoft.Extensions.Primitives.StringSegment tag, b } public static partial class HeaderNames { - public const string Accept = "Accept"; - public const string AcceptCharset = "Accept-Charset"; - public const string AcceptEncoding = "Accept-Encoding"; - public const string AcceptLanguage = "Accept-Language"; - public const string AcceptRanges = "Accept-Ranges"; - public const string AccessControlAllowCredentials = "Access-Control-Allow-Credentials"; - public const string AccessControlAllowHeaders = "Access-Control-Allow-Headers"; - public const string AccessControlAllowMethods = "Access-Control-Allow-Methods"; - public const string AccessControlAllowOrigin = "Access-Control-Allow-Origin"; - public const string AccessControlExposeHeaders = "Access-Control-Expose-Headers"; - public const string AccessControlMaxAge = "Access-Control-Max-Age"; - public const string AccessControlRequestHeaders = "Access-Control-Request-Headers"; - public const string AccessControlRequestMethod = "Access-Control-Request-Method"; - public const string Age = "Age"; - public const string Allow = "Allow"; - public const string Authority = ":authority"; - public const string Authorization = "Authorization"; - public const string CacheControl = "Cache-Control"; - public const string Connection = "Connection"; - public const string ContentDisposition = "Content-Disposition"; - public const string ContentEncoding = "Content-Encoding"; - public const string ContentLanguage = "Content-Language"; - public const string ContentLength = "Content-Length"; - public const string ContentLocation = "Content-Location"; - public const string ContentMD5 = "Content-MD5"; - public const string ContentRange = "Content-Range"; - public const string ContentSecurityPolicy = "Content-Security-Policy"; - public const string ContentSecurityPolicyReportOnly = "Content-Security-Policy-Report-Only"; - public const string ContentType = "Content-Type"; - public const string Cookie = "Cookie"; - public const string Date = "Date"; - public const string ETag = "ETag"; - public const string Expect = "Expect"; - public const string Expires = "Expires"; - public const string From = "From"; - public const string Host = "Host"; - public const string IfMatch = "If-Match"; - public const string IfModifiedSince = "If-Modified-Since"; - public const string IfNoneMatch = "If-None-Match"; - public const string IfRange = "If-Range"; - public const string IfUnmodifiedSince = "If-Unmodified-Since"; - public const string LastModified = "Last-Modified"; - public const string Location = "Location"; - public const string MaxForwards = "Max-Forwards"; - public const string Method = ":method"; - public const string Origin = "Origin"; - public const string Path = ":path"; - public const string Pragma = "Pragma"; - public const string ProxyAuthenticate = "Proxy-Authenticate"; - public const string ProxyAuthorization = "Proxy-Authorization"; - public const string Range = "Range"; - public const string Referer = "Referer"; - public const string RetryAfter = "Retry-After"; - public const string Scheme = ":scheme"; - public const string Server = "Server"; - public const string SetCookie = "Set-Cookie"; - public const string Status = ":status"; - public const string StrictTransportSecurity = "Strict-Transport-Security"; - public const string TE = "TE"; - public const string Trailer = "Trailer"; - public const string TransferEncoding = "Transfer-Encoding"; - public const string Upgrade = "Upgrade"; - public const string UserAgent = "User-Agent"; - public const string Vary = "Vary"; - public const string Via = "Via"; - public const string Warning = "Warning"; - public const string WebSocketSubProtocols = "Sec-WebSocket-Protocol"; - public const string WWWAuthenticate = "WWW-Authenticate"; + public static readonly string Accept; + public static readonly string AcceptCharset; + public static readonly string AcceptEncoding; + public static readonly string AcceptLanguage; + public static readonly string AcceptRanges; + public static readonly string AccessControlAllowCredentials; + public static readonly string AccessControlAllowHeaders; + public static readonly string AccessControlAllowMethods; + public static readonly string AccessControlAllowOrigin; + public static readonly string AccessControlExposeHeaders; + public static readonly string AccessControlMaxAge; + public static readonly string AccessControlRequestHeaders; + public static readonly string AccessControlRequestMethod; + public static readonly string Age; + public static readonly string Allow; + public static readonly string Authority; + public static readonly string Authorization; + public static readonly string CacheControl; + public static readonly string Connection; + public static readonly string ContentDisposition; + public static readonly string ContentEncoding; + public static readonly string ContentLanguage; + public static readonly string ContentLength; + public static readonly string ContentLocation; + public static readonly string ContentMD5; + public static readonly string ContentRange; + public static readonly string ContentSecurityPolicy; + public static readonly string ContentSecurityPolicyReportOnly; + public static readonly string ContentType; + public static readonly string Cookie; + public static readonly string CorrelationContext; + public static readonly string Date; + public static readonly string DNT; + public static readonly string ETag; + public static readonly string Expect; + public static readonly string Expires; + public static readonly string From; + public static readonly string Host; + public static readonly string IfMatch; + public static readonly string IfModifiedSince; + public static readonly string IfNoneMatch; + public static readonly string IfRange; + public static readonly string IfUnmodifiedSince; + public static readonly string KeepAlive; + public static readonly string LastModified; + public static readonly string Location; + public static readonly string MaxForwards; + public static readonly string Method; + public static readonly string Origin; + public static readonly string Path; + public static readonly string Pragma; + public static readonly string ProxyAuthenticate; + public static readonly string ProxyAuthorization; + public static readonly string Range; + public static readonly string Referer; + public static readonly string RequestId; + public static readonly string RetryAfter; + public static readonly string Scheme; + public static readonly string SecWebSocketAccept; + public static readonly string SecWebSocketKey; + public static readonly string SecWebSocketProtocol; + public static readonly string SecWebSocketVersion; + public static readonly string Server; + public static readonly string SetCookie; + public static readonly string Status; + public static readonly string StrictTransportSecurity; + public static readonly string TE; + public static readonly string TraceParent; + public static readonly string TraceState; + public static readonly string Trailer; + public static readonly string TransferEncoding; + public static readonly string Translate; + public static readonly string Upgrade; + public static readonly string UpgradeInsecureRequests; + public static readonly string UserAgent; + public static readonly string Vary; + public static readonly string Via; + public static readonly string Warning; + public static readonly string WebSocketSubProtocols; + public static readonly string WWWAuthenticate; + public static readonly string XFrameOptions; } public static partial class HeaderQuality { diff --git a/src/Http/Headers/src/HeaderNames.cs b/src/Http/Headers/src/HeaderNames.cs index fe79d242e8a3..602916254ac4 100644 --- a/src/Http/Headers/src/HeaderNames.cs +++ b/src/Http/Headers/src/HeaderNames.cs @@ -5,73 +5,87 @@ namespace Microsoft.Net.Http.Headers { public static class HeaderNames { - public const string Accept = "Accept"; - public const string AcceptCharset = "Accept-Charset"; - public const string AcceptEncoding = "Accept-Encoding"; - public const string AcceptLanguage = "Accept-Language"; - public const string AcceptRanges = "Accept-Ranges"; - public const string AccessControlAllowCredentials = "Access-Control-Allow-Credentials"; - public const string AccessControlAllowHeaders = "Access-Control-Allow-Headers"; - public const string AccessControlAllowMethods = "Access-Control-Allow-Methods"; - public const string AccessControlAllowOrigin = "Access-Control-Allow-Origin"; - public const string AccessControlExposeHeaders = "Access-Control-Expose-Headers"; - public const string AccessControlMaxAge = "Access-Control-Max-Age"; - public const string AccessControlRequestHeaders = "Access-Control-Request-Headers"; - public const string AccessControlRequestMethod = "Access-Control-Request-Method"; - public const string Age = "Age"; - public const string Allow = "Allow"; - public const string Authority = ":authority"; - public const string Authorization = "Authorization"; - public const string CacheControl = "Cache-Control"; - public const string Connection = "Connection"; - public const string ContentDisposition = "Content-Disposition"; - public const string ContentEncoding = "Content-Encoding"; - public const string ContentLanguage = "Content-Language"; - public const string ContentLength = "Content-Length"; - public const string ContentLocation = "Content-Location"; - public const string ContentMD5 = "Content-MD5"; - public const string ContentRange = "Content-Range"; - public const string ContentSecurityPolicy = "Content-Security-Policy"; - public const string ContentSecurityPolicyReportOnly = "Content-Security-Policy-Report-Only"; - public const string ContentType = "Content-Type"; - public const string Cookie = "Cookie"; - public const string Date = "Date"; - public const string ETag = "ETag"; - public const string Expires = "Expires"; - public const string Expect = "Expect"; - public const string From = "From"; - public const string Host = "Host"; - public const string IfMatch = "If-Match"; - public const string IfModifiedSince = "If-Modified-Since"; - public const string IfNoneMatch = "If-None-Match"; - public const string IfRange = "If-Range"; - public const string IfUnmodifiedSince = "If-Unmodified-Since"; - public const string LastModified = "Last-Modified"; - public const string Location = "Location"; - public const string MaxForwards = "Max-Forwards"; - public const string Method = ":method"; - public const string Origin = "Origin"; - public const string Path = ":path"; - public const string Pragma = "Pragma"; - public const string ProxyAuthenticate = "Proxy-Authenticate"; - public const string ProxyAuthorization = "Proxy-Authorization"; - public const string Range = "Range"; - public const string Referer = "Referer"; - public const string RetryAfter = "Retry-After"; - public const string Scheme = ":scheme"; - public const string Server = "Server"; - public const string SetCookie = "Set-Cookie"; - public const string Status = ":status"; - public const string StrictTransportSecurity = "Strict-Transport-Security"; - public const string TE = "TE"; - public const string Trailer = "Trailer"; - public const string TransferEncoding = "Transfer-Encoding"; - public const string Upgrade = "Upgrade"; - public const string UserAgent = "User-Agent"; - public const string Vary = "Vary"; - public const string Via = "Via"; - public const string Warning = "Warning"; - public const string WebSocketSubProtocols = "Sec-WebSocket-Protocol"; - public const string WWWAuthenticate = "WWW-Authenticate"; + // Use readonly statics rather than constants so ReferenceEquals works + public static readonly string Accept = "Accept"; + public static readonly string AcceptCharset = "Accept-Charset"; + public static readonly string AcceptEncoding = "Accept-Encoding"; + public static readonly string AcceptLanguage = "Accept-Language"; + public static readonly string AcceptRanges = "Accept-Ranges"; + public static readonly string AccessControlAllowCredentials = "Access-Control-Allow-Credentials"; + public static readonly string AccessControlAllowHeaders = "Access-Control-Allow-Headers"; + public static readonly string AccessControlAllowMethods = "Access-Control-Allow-Methods"; + public static readonly string AccessControlAllowOrigin = "Access-Control-Allow-Origin"; + public static readonly string AccessControlExposeHeaders = "Access-Control-Expose-Headers"; + public static readonly string AccessControlMaxAge = "Access-Control-Max-Age"; + public static readonly string AccessControlRequestHeaders = "Access-Control-Request-Headers"; + public static readonly string AccessControlRequestMethod = "Access-Control-Request-Method"; + public static readonly string Age = "Age"; + public static readonly string Allow = "Allow"; + public static readonly string Authority = ":authority"; + public static readonly string Authorization = "Authorization"; + public static readonly string CacheControl = "Cache-Control"; + public static readonly string Connection = "Connection"; + public static readonly string ContentDisposition = "Content-Disposition"; + public static readonly string ContentEncoding = "Content-Encoding"; + public static readonly string ContentLanguage = "Content-Language"; + public static readonly string ContentLength = "Content-Length"; + public static readonly string ContentLocation = "Content-Location"; + public static readonly string ContentMD5 = "Content-MD5"; + public static readonly string ContentRange = "Content-Range"; + public static readonly string ContentSecurityPolicy = "Content-Security-Policy"; + public static readonly string ContentSecurityPolicyReportOnly = "Content-Security-Policy-Report-Only"; + public static readonly string ContentType = "Content-Type"; + public static readonly string CorrelationContext = "Correlation-Context"; + public static readonly string Cookie = "Cookie"; + public static readonly string Date = "Date"; + public static readonly string DNT = "DNT"; + public static readonly string ETag = "ETag"; + public static readonly string Expires = "Expires"; + public static readonly string Expect = "Expect"; + public static readonly string From = "From"; + public static readonly string Host = "Host"; + public static readonly string KeepAlive = "Keep-Alive"; + public static readonly string IfMatch = "If-Match"; + public static readonly string IfModifiedSince = "If-Modified-Since"; + public static readonly string IfNoneMatch = "If-None-Match"; + public static readonly string IfRange = "If-Range"; + public static readonly string IfUnmodifiedSince = "If-Unmodified-Since"; + public static readonly string LastModified = "Last-Modified"; + public static readonly string Location = "Location"; + public static readonly string MaxForwards = "Max-Forwards"; + public static readonly string Method = ":method"; + public static readonly string Origin = "Origin"; + public static readonly string Path = ":path"; + public static readonly string Pragma = "Pragma"; + public static readonly string ProxyAuthenticate = "Proxy-Authenticate"; + public static readonly string ProxyAuthorization = "Proxy-Authorization"; + public static readonly string Range = "Range"; + public static readonly string Referer = "Referer"; + public static readonly string RetryAfter = "Retry-After"; + public static readonly string RequestId = "Request-Id"; + public static readonly string Scheme = ":scheme"; + public static readonly string SecWebSocketAccept = "Sec-WebSocket-Accept"; + public static readonly string SecWebSocketKey = "Sec-WebSocket-Key"; + public static readonly string SecWebSocketProtocol = "Sec-WebSocket-Protocol"; + public static readonly string SecWebSocketVersion = "Sec-WebSocket-Version"; + public static readonly string Server = "Server"; + public static readonly string SetCookie = "Set-Cookie"; + public static readonly string Status = ":status"; + public static readonly string StrictTransportSecurity = "Strict-Transport-Security"; + public static readonly string TE = "TE"; + public static readonly string Trailer = "Trailer"; + public static readonly string TransferEncoding = "Transfer-Encoding"; + public static readonly string Translate = "Translate"; + public static readonly string TraceParent = "traceparent"; + public static readonly string TraceState = "tracestate"; + public static readonly string Upgrade = "Upgrade"; + public static readonly string UpgradeInsecureRequests = "Upgrade-Insecure-Requests"; + public static readonly string UserAgent = "User-Agent"; + public static readonly string Vary = "Vary"; + public static readonly string Via = "Via"; + public static readonly string Warning = "Warning"; + public static readonly string WebSocketSubProtocols = "Sec-WebSocket-Protocol"; + public static readonly string WWWAuthenticate = "WWW-Authenticate"; + public static readonly string XFrameOptions = "X-Frame-Options"; } } diff --git a/src/Http/Http.Abstractions/ref/Microsoft.AspNetCore.Http.Abstractions.csproj b/src/Http/Http.Abstractions/ref/Microsoft.AspNetCore.Http.Abstractions.csproj index 6c6e2c7739e9..d4db5e191949 100644 --- a/src/Http/Http.Abstractions/ref/Microsoft.AspNetCore.Http.Abstractions.csproj +++ b/src/Http/Http.Abstractions/ref/Microsoft.AspNetCore.Http.Abstractions.csproj @@ -7,6 +7,7 @@ + diff --git a/src/Http/Http.Abstractions/src/Extensions/ResponseTrailerExtensions.cs b/src/Http/Http.Abstractions/src/Extensions/ResponseTrailerExtensions.cs index 745cbfd9de47..684dcdd164df 100644 --- a/src/Http/Http.Abstractions/src/Extensions/ResponseTrailerExtensions.cs +++ b/src/Http/Http.Abstractions/src/Extensions/ResponseTrailerExtensions.cs @@ -4,13 +4,12 @@ using System; using Microsoft.AspNetCore.Http.Features; using Microsoft.Extensions.Primitives; +using Microsoft.Net.Http.Headers; namespace Microsoft.AspNetCore.Http { public static class ResponseTrailerExtensions { - private const string Trailer = "Trailer"; - /// /// Adds the given trailer name to the 'Trailer' response header. This must happen before the response headers are sent. /// @@ -18,7 +17,7 @@ public static class ResponseTrailerExtensions /// public static void DeclareTrailer(this HttpResponse response, string trailerName) { - response.Headers.AppendCommaSeparatedValues(Trailer, trailerName); + response.Headers.AppendCommaSeparatedValues(HeaderNames.Trailer, trailerName); } /// diff --git a/src/Http/Http.Abstractions/src/Microsoft.AspNetCore.Http.Abstractions.csproj b/src/Http/Http.Abstractions/src/Microsoft.AspNetCore.Http.Abstractions.csproj index bfe8d8399f9a..d5b065b3d855 100644 --- a/src/Http/Http.Abstractions/src/Microsoft.AspNetCore.Http.Abstractions.csproj +++ b/src/Http/Http.Abstractions/src/Microsoft.AspNetCore.Http.Abstractions.csproj @@ -22,6 +22,7 @@ Microsoft.AspNetCore.Http.HttpResponse + diff --git a/src/Http/Http/src/Internal/DefaultHttpRequest.cs b/src/Http/Http/src/Internal/DefaultHttpRequest.cs index b82359e9859b..964a4785104d 100644 --- a/src/Http/Http/src/Internal/DefaultHttpRequest.cs +++ b/src/Http/Http/src/Internal/DefaultHttpRequest.cs @@ -116,8 +116,8 @@ public override bool IsHttps public override HostString Host { - get { return HostString.FromUriComponent(Headers["Host"]); } - set { Headers["Host"] = value.ToUriComponent(); } + get { return HostString.FromUriComponent(Headers[HeaderNames.Host]); } + set { Headers[HeaderNames.Host] = value.ToUriComponent(); } } public override IQueryCollection Query diff --git a/src/Http/Http/src/Internal/FormFile.cs b/src/Http/Http/src/Internal/FormFile.cs index b4a3f4d91f40..fe541ae85702 100644 --- a/src/Http/Http/src/Internal/FormFile.cs +++ b/src/Http/Http/src/Internal/FormFile.cs @@ -5,6 +5,7 @@ using System.IO; using System.Threading; using System.Threading.Tasks; +using Microsoft.Net.Http.Headers; namespace Microsoft.AspNetCore.Http.Internal { @@ -30,8 +31,8 @@ public FormFile(Stream baseStream, long baseStreamOffset, long length, string na /// public string ContentDisposition { - get { return Headers["Content-Disposition"]; } - set { Headers["Content-Disposition"] = value; } + get { return Headers[HeaderNames.ContentDisposition]; } + set { Headers[HeaderNames.ContentDisposition] = value; } } /// @@ -39,8 +40,8 @@ public string ContentDisposition /// public string ContentType { - get { return Headers["Content-Type"]; } - set { Headers["Content-Type"] = value; } + get { return Headers[HeaderNames.ContentType]; } + set { Headers[HeaderNames.ContentType] = value; } } /// diff --git a/src/Http/Routing/src/Matching/HttpMethodMatcherPolicy.cs b/src/Http/Routing/src/Matching/HttpMethodMatcherPolicy.cs index 6e7d2d069b0c..3111c55a67a4 100644 --- a/src/Http/Routing/src/Matching/HttpMethodMatcherPolicy.cs +++ b/src/Http/Routing/src/Matching/HttpMethodMatcherPolicy.cs @@ -391,7 +391,7 @@ private Endpoint CreateRejectionEndpoint(IEnumerable httpMethods) // Prevent ArgumentException from duplicate key if header already added, such as when the // request is re-executed by an error handler (see https://github.com/aspnet/AspNetCore/issues/6415) - context.Response.Headers["Allow"] = allow; + context.Response.Headers[HeaderNames.Allow] = allow; return Task.CompletedTask; }, diff --git a/src/Http/WebUtilities/src/MultipartSection.cs b/src/Http/WebUtilities/src/MultipartSection.cs index 96138c630a10..cba78617d16b 100644 --- a/src/Http/WebUtilities/src/MultipartSection.cs +++ b/src/Http/WebUtilities/src/MultipartSection.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.IO; using Microsoft.Extensions.Primitives; +using Microsoft.Net.Http.Headers; namespace Microsoft.AspNetCore.WebUtilities { @@ -14,7 +15,7 @@ public string ContentType get { StringValues values; - if (Headers.TryGetValue("Content-Type", out values)) + if (Headers.TryGetValue(HeaderNames.ContentType, out values)) { return values; } @@ -27,7 +28,7 @@ public string ContentDisposition get { StringValues values; - if (Headers.TryGetValue("Content-Disposition", out values)) + if (Headers.TryGetValue(HeaderNames.ContentDisposition, out values)) { return values; } @@ -45,4 +46,4 @@ public string ContentDisposition /// public long? BaseStreamOffset { get; set; } } -} \ No newline at end of file +} diff --git a/src/Middleware/Session/src/SessionMiddleware.cs b/src/Middleware/Session/src/SessionMiddleware.cs index bd74afa9cb52..d3eceb4d2bd7 100644 --- a/src/Middleware/Session/src/SessionMiddleware.cs +++ b/src/Middleware/Session/src/SessionMiddleware.cs @@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Http.Features; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; +using Microsoft.Net.Http.Headers; namespace Microsoft.AspNetCore.Session { @@ -159,9 +160,9 @@ private void SetCookie() _context.Response.Cookies.Append(_options.Cookie.Name, _cookieValue, cookieOptions); - _context.Response.Headers["Cache-Control"] = "no-cache"; - _context.Response.Headers["Pragma"] = "no-cache"; - _context.Response.Headers["Expires"] = "-1"; + _context.Response.Headers[HeaderNames.CacheControl] = "no-cache"; + _context.Response.Headers[HeaderNames.Pragma] = "no-cache"; + _context.Response.Headers[HeaderNames.Expires] = "-1"; } // Returns true if the session has already been established, or if it still can be because the response has not been sent. @@ -171,4 +172,4 @@ internal bool TryEstablishSession() } } } -} \ No newline at end of file +} diff --git a/src/Middleware/WebSockets/ref/Microsoft.AspNetCore.WebSockets.netcoreapp3.0.cs b/src/Middleware/WebSockets/ref/Microsoft.AspNetCore.WebSockets.netcoreapp3.0.cs index f0cec99aabe7..6b2b1988b3af 100644 --- a/src/Middleware/WebSockets/ref/Microsoft.AspNetCore.WebSockets.netcoreapp3.0.cs +++ b/src/Middleware/WebSockets/ref/Microsoft.AspNetCore.WebSockets.netcoreapp3.0.cs @@ -35,21 +35,3 @@ public static partial class WebSocketsDependencyInjectionExtensions public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddWebSockets(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Action configure) { throw null; } } } -namespace Microsoft.AspNetCore.WebSockets.Internal -{ - public static partial class Constants - { - public static partial class Headers - { - public const string Connection = "Connection"; - public const string ConnectionUpgrade = "Upgrade"; - public const string SecWebSocketAccept = "Sec-WebSocket-Accept"; - public const string SecWebSocketKey = "Sec-WebSocket-Key"; - public const string SecWebSocketProtocol = "Sec-WebSocket-Protocol"; - public const string SecWebSocketVersion = "Sec-WebSocket-Version"; - public const string SupportedVersion = "13"; - public const string Upgrade = "Upgrade"; - public const string UpgradeWebSocket = "websocket"; - } - } -} diff --git a/src/Middleware/WebSockets/src/Internal/Constants.cs b/src/Middleware/WebSockets/src/Internal/Constants.cs index ffc5db2c14b6..8fb17cf9c0e9 100644 --- a/src/Middleware/WebSockets/src/Internal/Constants.cs +++ b/src/Middleware/WebSockets/src/Internal/Constants.cs @@ -3,18 +3,12 @@ namespace Microsoft.AspNetCore.WebSockets.Internal { - public static class Constants + internal static class Constants { public static class Headers - { - public const string Upgrade = "Upgrade"; - public const string UpgradeWebSocket = "websocket"; - public const string Connection = "Connection"; + { + public const string UpgradeWebSocket = "websocket"; public const string ConnectionUpgrade = "Upgrade"; - public const string SecWebSocketKey = "Sec-WebSocket-Key"; - public const string SecWebSocketVersion = "Sec-WebSocket-Version"; - public const string SecWebSocketProtocol = "Sec-WebSocket-Protocol"; - public const string SecWebSocketAccept = "Sec-WebSocket-Accept"; public const string SupportedVersion = "13"; } } diff --git a/src/Middleware/WebSockets/src/Internal/HandshakeHelpers.cs b/src/Middleware/WebSockets/src/Internal/HandshakeHelpers.cs index c001e9318e2f..551ca879c91f 100644 --- a/src/Middleware/WebSockets/src/Internal/HandshakeHelpers.cs +++ b/src/Middleware/WebSockets/src/Internal/HandshakeHelpers.cs @@ -6,6 +6,7 @@ using System.Security.Cryptography; using System.Text; using Microsoft.AspNetCore.Http; +using Microsoft.Net.Http.Headers; namespace Microsoft.AspNetCore.WebSockets.Internal { @@ -16,10 +17,10 @@ internal static class HandshakeHelpers /// public static readonly IEnumerable NeededHeaders = new[] { - Constants.Headers.Upgrade, - Constants.Headers.Connection, - Constants.Headers.SecWebSocketKey, - Constants.Headers.SecWebSocketVersion + HeaderNames.Upgrade, + HeaderNames.Connection, + HeaderNames.SecWebSocketKey, + HeaderNames.SecWebSocketVersion }; // Verify Method, Upgrade, Connection, version, key, etc.. @@ -34,28 +35,28 @@ public static bool CheckSupportedWebSocketRequest(string method, IEnumerable AcceptAsync(WebSocketAcceptContext acceptContext) } } - string key = string.Join(", ", _context.Request.Headers[Constants.Headers.SecWebSocketKey]); + string key = string.Join(", ", _context.Request.Headers[HeaderNames.SecWebSocketKey]); HandshakeHelpers.GenerateResponseHeaders(key, subProtocol, _context.Response.Headers); diff --git a/src/Middleware/WebSockets/test/UnitTests/WebSocketMiddlewareTests.cs b/src/Middleware/WebSockets/test/UnitTests/WebSocketMiddlewareTests.cs index d010a00c4b95..61b310f1b0aa 100644 --- a/src/Middleware/WebSockets/test/UnitTests/WebSocketMiddlewareTests.cs +++ b/src/Middleware/WebSockets/test/UnitTests/WebSocketMiddlewareTests.cs @@ -12,6 +12,7 @@ using Microsoft.AspNetCore.Testing.xunit; using Microsoft.AspNetCore.WebSockets.Internal; using Microsoft.Extensions.Logging.Testing; +using Microsoft.Net.Http.Headers; using Xunit; namespace Microsoft.AspNetCore.WebSockets.Test @@ -537,11 +538,11 @@ public async Task OriginIsValidatedForWebSocketRequests(HttpStatusCode expectedC request.Headers.Connection.Clear(); request.Headers.Connection.Add("Upgrade"); request.Headers.Upgrade.Add(new System.Net.Http.Headers.ProductHeaderValue("websocket")); - request.Headers.Add(Constants.Headers.SecWebSocketVersion, Constants.Headers.SupportedVersion); + request.Headers.Add(HeaderNames.SecWebSocketVersion, "13"); // SecWebSocketKey required to be 16 bytes - request.Headers.Add(Constants.Headers.SecWebSocketKey, Convert.ToBase64String(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }, Base64FormattingOptions.None)); + request.Headers.Add(HeaderNames.SecWebSocketKey, Convert.ToBase64String(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }, Base64FormattingOptions.None)); - request.Headers.Add("Origin", "http://example.com"); + request.Headers.Add(HeaderNames.Origin, "http://example.com"); var response = await client.SendAsync(request); Assert.Equal(expectedCode, response.StatusCode); diff --git a/src/Mvc/test/Mvc.FunctionalTests/RequestServicesTestBase.cs b/src/Mvc/test/Mvc.FunctionalTests/RequestServicesTestBase.cs index cc4e06ba74be..840d070bc258 100644 --- a/src/Mvc/test/Mvc.FunctionalTests/RequestServicesTestBase.cs +++ b/src/Mvc/test/Mvc.FunctionalTests/RequestServicesTestBase.cs @@ -7,6 +7,7 @@ using System.Net.Http; using System.Threading.Tasks; using Microsoft.AspNetCore.Hosting; +using Microsoft.Net.Http.Headers; using Xunit; namespace Microsoft.AspNetCore.Mvc.FunctionalTests @@ -41,7 +42,7 @@ public async Task RequestServices(string url) // Arrange var requestId = Guid.NewGuid().ToString(); var request = new HttpRequestMessage(HttpMethod.Get, url); - request.Headers.TryAddWithoutValidation("RequestId", requestId); + request.Headers.TryAddWithoutValidation(HeaderNames.RequestId, requestId); // Act var response = await Client.SendAsync(request); @@ -64,7 +65,7 @@ public async Task RequestServices_TagHelper() { var requestId = Guid.NewGuid().ToString(); var request = new HttpRequestMessage(HttpMethod.Get, url); - request.Headers.TryAddWithoutValidation("RequestId", requestId); + request.Headers.TryAddWithoutValidation(HeaderNames.RequestId, requestId); var response = await Client.SendAsync(request); @@ -84,7 +85,7 @@ public async Task RequestServices_Constraint() // Act & Assert var requestId1 = "b40f6ec1-8a6b-41c1-b3fe-928f581ebaf5"; var request1 = new HttpRequestMessage(HttpMethod.Get, url); - request1.Headers.TryAddWithoutValidation("RequestId", requestId1); + request1.Headers.TryAddWithoutValidation(HeaderNames.RequestId, requestId1); var response1 = await Client.SendAsync(request1); @@ -93,7 +94,7 @@ public async Task RequestServices_Constraint() var requestId2 = Guid.NewGuid().ToString(); var request2 = new HttpRequestMessage(HttpMethod.Get, url); - request2.Headers.TryAddWithoutValidation("RequestId", requestId2); + request2.Headers.TryAddWithoutValidation(HeaderNames.RequestId, requestId2); var response2 = await Client.SendAsync(request2); Assert.Equal(HttpStatusCode.NotFound, response2.StatusCode); diff --git a/src/Mvc/test/WebSites/BasicWebSite/RequestIdMiddleware.cs b/src/Mvc/test/WebSites/BasicWebSite/RequestIdMiddleware.cs index 22d606ea91c1..fd2227bf23bf 100644 --- a/src/Mvc/test/WebSites/BasicWebSite/RequestIdMiddleware.cs +++ b/src/Mvc/test/WebSites/BasicWebSite/RequestIdMiddleware.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Net.Http.Headers; namespace BasicWebSite { @@ -26,7 +27,7 @@ public Task Invoke(HttpContext context) throw new InvalidOperationException("RequestId should be null here"); } - var requestId = context.Request.Headers["RequestId"]; + var requestId = context.Request.Headers[HeaderNames.RequestId]; requestIdService.RequestId = requestId; return _next(context); diff --git a/src/Security/Authentication/Cookies/src/CookieAuthenticationEvents.cs b/src/Security/Authentication/Cookies/src/CookieAuthenticationEvents.cs index 2b8b0416b3ba..a6bb4e7d1c60 100644 --- a/src/Security/Authentication/Cookies/src/CookieAuthenticationEvents.cs +++ b/src/Security/Authentication/Cookies/src/CookieAuthenticationEvents.cs @@ -4,6 +4,7 @@ using System; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; +using Microsoft.Net.Http.Headers; namespace Microsoft.AspNetCore.Authentication.Cookies { @@ -41,7 +42,7 @@ public class CookieAuthenticationEvents { if (IsAjaxRequest(context.Request)) { - context.Response.Headers["Location"] = context.RedirectUri; + context.Response.Headers[HeaderNames.Location] = context.RedirectUri; context.Response.StatusCode = 401; } else @@ -58,7 +59,7 @@ public class CookieAuthenticationEvents { if (IsAjaxRequest(context.Request)) { - context.Response.Headers["Location"] = context.RedirectUri; + context.Response.Headers[HeaderNames.Location] = context.RedirectUri; context.Response.StatusCode = 403; } else @@ -75,7 +76,7 @@ public class CookieAuthenticationEvents { if (IsAjaxRequest(context.Request)) { - context.Response.Headers["Location"] = context.RedirectUri; + context.Response.Headers[HeaderNames.Location] = context.RedirectUri; } else { @@ -91,7 +92,7 @@ public class CookieAuthenticationEvents { if (IsAjaxRequest(context.Request)) { - context.Response.Headers["Location"] = context.RedirectUri; + context.Response.Headers[HeaderNames.Location] = context.RedirectUri; } else { @@ -155,4 +156,4 @@ private static bool IsAjaxRequest(HttpRequest request) /// Contains information about the event public virtual Task RedirectToAccessDenied(RedirectContext context) => OnRedirectToAccessDenied(context); } -} \ No newline at end of file +} diff --git a/src/Security/Authentication/JwtBearer/src/JwtBearerHandler.cs b/src/Security/Authentication/JwtBearer/src/JwtBearerHandler.cs index 72d3a3bd2903..8fcc6eb50cbc 100644 --- a/src/Security/Authentication/JwtBearer/src/JwtBearerHandler.cs +++ b/src/Security/Authentication/JwtBearer/src/JwtBearerHandler.cs @@ -63,7 +63,7 @@ protected override async Task HandleAuthenticateAsync() if (string.IsNullOrEmpty(token)) { - string authorization = Request.Headers["Authorization"]; + string authorization = Request.Headers[HeaderNames.Authorization]; // If no authorization header found, nothing to process further if (string.IsNullOrEmpty(authorization)) diff --git a/src/Servers/Kestrel/Core/src/Internal/Http/HttpHeaders.Generated.cs b/src/Servers/Kestrel/Core/src/Internal/Http/HttpHeaders.Generated.cs index 55882f905d44..6c85c81a68b0 100644 --- a/src/Servers/Kestrel/Core/src/Internal/Http/HttpHeaders.Generated.cs +++ b/src/Servers/Kestrel/Core/src/Internal/Http/HttpHeaders.Generated.cs @@ -737,20 +737,88 @@ public StringValues HeaderUpgradeInsecureRequests _headers._UpgradeInsecureRequests = value; } } - public StringValues HeaderOrigin + public StringValues HeaderRequestId { get { StringValues value = default; if ((_bits & 0x40000000000L) != 0) { - value = _headers._Origin; + value = _headers._RequestId; } return value; } set { _bits |= 0x40000000000L; + _headers._RequestId = value; + } + } + public StringValues HeaderCorrelationContext + { + get + { + StringValues value = default; + if ((_bits & 0x80000000000L) != 0) + { + value = _headers._CorrelationContext; + } + return value; + } + set + { + _bits |= 0x80000000000L; + _headers._CorrelationContext = value; + } + } + public StringValues HeaderTraceParent + { + get + { + StringValues value = default; + if ((_bits & 0x100000000000L) != 0) + { + value = _headers._TraceParent; + } + return value; + } + set + { + _bits |= 0x100000000000L; + _headers._TraceParent = value; + } + } + public StringValues HeaderTraceState + { + get + { + StringValues value = default; + if ((_bits & 0x200000000000L) != 0) + { + value = _headers._TraceState; + } + return value; + } + set + { + _bits |= 0x200000000000L; + _headers._TraceState = value; + } + } + public StringValues HeaderOrigin + { + get + { + StringValues value = default; + if ((_bits & 0x400000000000L) != 0) + { + value = _headers._Origin; + } + return value; + } + set + { + _bits |= 0x400000000000L; _headers._Origin = value; } } @@ -759,7 +827,7 @@ public StringValues HeaderAccessControlRequestMethod get { StringValues value = default; - if ((_bits & 0x80000000000L) != 0) + if ((_bits & 0x800000000000L) != 0) { value = _headers._AccessControlRequestMethod; } @@ -767,7 +835,7 @@ public StringValues HeaderAccessControlRequestMethod } set { - _bits |= 0x80000000000L; + _bits |= 0x800000000000L; _headers._AccessControlRequestMethod = value; } } @@ -776,7 +844,7 @@ public StringValues HeaderAccessControlRequestHeaders get { StringValues value = default; - if ((_bits & 0x100000000000L) != 0) + if ((_bits & 0x1000000000000L) != 0) { value = _headers._AccessControlRequestHeaders; } @@ -784,7 +852,7 @@ public StringValues HeaderAccessControlRequestHeaders } set { - _bits |= 0x100000000000L; + _bits |= 0x1000000000000L; _headers._AccessControlRequestHeaders = value; } } @@ -815,5948 +883,9391 @@ protected override bool TryGetValueFast(string key, out StringValues value) value = default; switch (key.Length) { - case 13: + case 2: + { + if (ReferenceEquals(HeaderNames.TE, key)) { - if ("Cache-Control".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x2000000000L) != 0) { - if ((_bits & 0x1L) != 0) - { - value = _headers._CacheControl; - return true; - } - return false; + value = _headers._TE; + return true; } - if ("Content-Range".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + + if (HeaderNames.TE.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x2000000000L) != 0) { - if ((_bits & 0x10000L) != 0) - { - value = _headers._ContentRange; - return true; - } - return false; + value = _headers._TE; + return true; } - if ("Last-Modified".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + break; + } + case 3: + { + if (ReferenceEquals(HeaderNames.Via, key)) + { + if ((_bits & 0x100L) != 0) { - if ((_bits & 0x40000L) != 0) - { - value = _headers._LastModified; - return true; - } - return false; + value = _headers._Via; + return true; } - if ("Authorization".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (ReferenceEquals(HeaderNames.DNT, key)) + { + if ((_bits & 0x10000000000L) != 0) { - if ((_bits & 0x800000L) != 0) - { - value = _headers._Authorization; - return true; - } - return false; + value = _headers._DNT; + return true; + } + return false; + } + + if (HeaderNames.Via.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x100L) != 0) + { + value = _headers._Via; + return true; } - if ("If-None-Match".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (HeaderNames.DNT.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x10000000000L) != 0) { - if ((_bits & 0x40000000L) != 0) - { - value = _headers._IfNoneMatch; - return true; - } - return false; + value = _headers._DNT; + return true; } + return false; } break; - case 10: + } + case 4: + { + if (ReferenceEquals(HeaderNames.Host, key)) { - if ("Connection".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x8000000L) != 0) { - if ((_bits & 0x2L) != 0) - { - value = _headers._Connection; - return true; - } - return false; + value = _headers._Host; + return true; } - if ("Keep-Alive".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (ReferenceEquals(HeaderNames.Date, key)) + { + if ((_bits & 0x4L) != 0) { - if ((_bits & 0x8L) != 0) - { - value = _headers._KeepAlive; - return true; - } - return false; + value = _headers._Date; + return true; } - if ("User-Agent".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (ReferenceEquals(HeaderNames.From, key)) + { + if ((_bits & 0x4000000L) != 0) { - if ((_bits & 0x8000000000L) != 0) - { - value = _headers._UserAgent; - return true; - } - return false; + value = _headers._From; + return true; } + return false; } - break; - case 4: + + if (HeaderNames.Host.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Date".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x8000000L) != 0) { - if ((_bits & 0x4L) != 0) - { - value = _headers._Date; - return true; - } - return false; + value = _headers._Host; + return true; } - if ("From".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (HeaderNames.Date.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x4L) != 0) { - if ((_bits & 0x4000000L) != 0) - { - value = _headers._From; - return true; - } - return false; + value = _headers._Date; + return true; } - if ("Host".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (HeaderNames.From.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x4000000L) != 0) { - if ((_bits & 0x8000000L) != 0) - { - value = _headers._Host; - return true; - } - return false; + value = _headers._From; + return true; } + return false; } break; - case 6: + } + case 5: + { + if (ReferenceEquals(HeaderNames.Allow, key)) { - if ("Pragma".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x400L) != 0) { - if ((_bits & 0x10L) != 0) - { - value = _headers._Pragma; - return true; - } - return false; + value = _headers._Allow; + return true; } - if ("Accept".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (ReferenceEquals(HeaderNames.Range, key)) + { + if ((_bits & 0x1000000000L) != 0) { - if ((_bits & 0x80000L) != 0) - { - value = _headers._Accept; - return true; - } - return false; + value = _headers._Range; + return true; } - if ("Cookie".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + + if (HeaderNames.Allow.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x400L) != 0) { - if ((_bits & 0x1000000L) != 0) - { - value = _headers._Cookie; - return true; - } - return false; + value = _headers._Allow; + return true; } - if ("Expect".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (HeaderNames.Range.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x1000000000L) != 0) { - if ((_bits & 0x2000000L) != 0) - { - value = _headers._Expect; - return true; - } - return false; + value = _headers._Range; + return true; } - if ("Origin".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + break; + } + case 6: + { + if (ReferenceEquals(HeaderNames.Accept, key)) + { + if ((_bits & 0x80000L) != 0) { - if ((_bits & 0x40000000000L) != 0) - { - value = _headers._Origin; - return true; - } - return false; + value = _headers._Accept; + return true; } + return false; } - break; - case 7: + if (ReferenceEquals(HeaderNames.Pragma, key)) { - if ("Trailer".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x10L) != 0) { - if ((_bits & 0x20L) != 0) - { - value = _headers._Trailer; - return true; - } - return false; + value = _headers._Pragma; + return true; } - if ("Upgrade".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (ReferenceEquals(HeaderNames.Cookie, key)) + { + if ((_bits & 0x1000000L) != 0) { - if ((_bits & 0x80L) != 0) - { - value = _headers._Upgrade; - return true; - } - return false; + value = _headers._Cookie; + return true; } - if ("Warning".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (ReferenceEquals(HeaderNames.Expect, key)) + { + if ((_bits & 0x2000000L) != 0) { - if ((_bits & 0x200L) != 0) - { - value = _headers._Warning; - return true; - } - return false; + value = _headers._Expect; + return true; } - if ("Expires".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (ReferenceEquals(HeaderNames.Origin, key)) + { + if ((_bits & 0x400000000000L) != 0) { - if ((_bits & 0x20000L) != 0) - { - value = _headers._Expires; - return true; - } - return false; + value = _headers._Origin; + return true; } - if ("Referer".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + + if (HeaderNames.Accept.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x80000L) != 0) { - if ((_bits & 0x800000000L) != 0) - { - value = _headers._Referer; - return true; - } - return false; + value = _headers._Accept; + return true; } + return false; } - break; - case 17: + if (HeaderNames.Pragma.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Transfer-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x10L) != 0) { - if ((_bits & 0x40L) != 0) - { - value = _headers._TransferEncoding; - return true; - } - return false; + value = _headers._Pragma; + return true; } - if ("If-Modified-Since".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (HeaderNames.Cookie.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x1000000L) != 0) { - if ((_bits & 0x20000000L) != 0) - { - value = _headers._IfModifiedSince; - return true; - } - return false; + value = _headers._Cookie; + return true; } + return false; } - break; - case 3: + if (HeaderNames.Expect.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Via".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x2000000L) != 0) { - if ((_bits & 0x100L) != 0) - { - value = _headers._Via; - return true; - } - return false; + value = _headers._Expect; + return true; } - if ("DNT".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (HeaderNames.Origin.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x400000000000L) != 0) { - if ((_bits & 0x10000000000L) != 0) - { - value = _headers._DNT; - return true; - } - return false; + value = _headers._Origin; + return true; } + return false; } break; - case 5: + } + case 7: + { + if (ReferenceEquals(HeaderNames.Trailer, key)) { - if ("Allow".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x20L) != 0) { - if ((_bits & 0x400L) != 0) - { - value = _headers._Allow; - return true; - } - return false; + value = _headers._Trailer; + return true; } - if ("Range".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (ReferenceEquals(HeaderNames.Upgrade, key)) + { + if ((_bits & 0x80L) != 0) { - if ((_bits & 0x1000000000L) != 0) - { - value = _headers._Range; - return true; - } - return false; + value = _headers._Upgrade; + return true; } + return false; } - break; - case 12: + if (ReferenceEquals(HeaderNames.Warning, key)) { - if ("Content-Type".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x200L) != 0) { - if ((_bits & 0x800L) != 0) - { - value = _headers._ContentType; - return true; - } - return false; + value = _headers._Warning; + return true; } - if ("Max-Forwards".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (ReferenceEquals(HeaderNames.Expires, key)) + { + if ((_bits & 0x20000L) != 0) { - if ((_bits & 0x200000000L) != 0) - { - value = _headers._MaxForwards; - return true; - } - return false; + value = _headers._Expires; + return true; } + return false; } - break; - case 16: + if (ReferenceEquals(HeaderNames.Referer, key)) { - if ("Content-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x800000000L) != 0) { - if ((_bits & 0x1000L) != 0) - { - value = _headers._ContentEncoding; - return true; - } - return false; + value = _headers._Referer; + return true; } - if ("Content-Language".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + + if (HeaderNames.Trailer.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x20L) != 0) { - if ((_bits & 0x2000L) != 0) - { - value = _headers._ContentLanguage; - return true; - } - return false; + value = _headers._Trailer; + return true; } - if ("Content-Location".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (HeaderNames.Upgrade.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x80L) != 0) { - if ((_bits & 0x4000L) != 0) - { - value = _headers._ContentLocation; - return true; - } - return false; + value = _headers._Upgrade; + return true; } + return false; } - break; - case 11: + if (HeaderNames.Warning.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Content-MD5".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x200L) != 0) { - if ((_bits & 0x8000L) != 0) - { - value = _headers._ContentMD5; - return true; - } - return false; + value = _headers._Warning; + return true; } + return false; } - break; - case 14: + if (HeaderNames.Expires.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Accept-Charset".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x20000L) != 0) { - if ((_bits & 0x100000L) != 0) - { - value = _headers._AcceptCharset; - return true; - } - return false; - } - if ("Content-Length".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if (_contentLength.HasValue) - { - value = HeaderUtilities.FormatNonNegativeInt64(_contentLength.Value); - return true; - } - return false; + value = _headers._Expires; + return true; } + return false; } - break; - case 15: + if (HeaderNames.Referer.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Accept-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x200000L) != 0) - { - value = _headers._AcceptEncoding; - return true; - } - return false; - } - if ("Accept-Language".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x800000000L) != 0) { - if ((_bits & 0x400000L) != 0) - { - value = _headers._AcceptLanguage; - return true; - } - return false; + value = _headers._Referer; + return true; } + return false; } break; + } case 8: + { + if (ReferenceEquals(HeaderNames.IfMatch, key)) { - if ("If-Match".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x10000000L) != 0) - { - value = _headers._IfMatch; - return true; - } - return false; - } - if ("If-Range".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x10000000L) != 0) { - if ((_bits & 0x80000000L) != 0) - { - value = _headers._IfRange; - return true; - } - return false; + value = _headers._IfMatch; + return true; } + return false; } - break; - case 19: + if (ReferenceEquals(HeaderNames.IfRange, key)) { - if ("If-Unmodified-Since".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x80000000L) != 0) { - if ((_bits & 0x100000000L) != 0) - { - value = _headers._IfUnmodifiedSince; - return true; - } - return false; + value = _headers._IfRange; + return true; } - if ("Proxy-Authorization".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + + if (HeaderNames.IfMatch.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x10000000L) != 0) { - if ((_bits & 0x400000000L) != 0) - { - value = _headers._ProxyAuthorization; - return true; - } - return false; + value = _headers._IfMatch; + return true; } + return false; } - break; - case 2: + if (HeaderNames.IfRange.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("TE".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x80000000L) != 0) { - if ((_bits & 0x2000000000L) != 0) - { - value = _headers._TE; - return true; - } - return false; + value = _headers._IfRange; + return true; } + return false; } break; + } case 9: + { + if (ReferenceEquals(HeaderNames.Translate, key)) { - if ("Translate".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x4000000000L) != 0) { - if ((_bits & 0x4000000000L) != 0) - { - value = _headers._Translate; - return true; - } - return false; + value = _headers._Translate; + return true; } + return false; } - break; - case 25: + + if (HeaderNames.Translate.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Upgrade-Insecure-Requests".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x4000000000L) != 0) { - if ((_bits & 0x20000000000L) != 0) - { - value = _headers._UpgradeInsecureRequests; - return true; - } - return false; + value = _headers._Translate; + return true; } + return false; } break; - case 29: + } + case 10: + { + if (ReferenceEquals(HeaderNames.Connection, key)) { - if ("Access-Control-Request-Method".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x2L) != 0) { - if ((_bits & 0x80000000000L) != 0) - { - value = _headers._AccessControlRequestMethod; - return true; - } - return false; + value = _headers._Connection; + return true; } + return false; } - break; - case 30: + if (ReferenceEquals(HeaderNames.UserAgent, key)) { - if ("Access-Control-Request-Headers".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x8000000000L) != 0) { - if ((_bits & 0x100000000000L) != 0) - { - value = _headers._AccessControlRequestHeaders; - return true; - } - return false; + value = _headers._UserAgent; + return true; } + return false; } - break; - } - - return MaybeUnknown?.TryGetValue(key, out value) ?? false; - } - - protected override void SetValueFast(string key, StringValues value) - { - switch (key.Length) - { - case 13: + if (ReferenceEquals(HeaderNames.KeepAlive, key)) { - if ("Cache-Control".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x8L) != 0) { - _bits |= 0x1L; - _headers._CacheControl = value; - return; + value = _headers._KeepAlive; + return true; } - if ("Content-Range".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (ReferenceEquals(HeaderNames.RequestId, key)) + { + if ((_bits & 0x40000000000L) != 0) { - _bits |= 0x10000L; - _headers._ContentRange = value; - return; + value = _headers._RequestId; + return true; } - if ("Last-Modified".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (ReferenceEquals(HeaderNames.TraceState, key)) + { + if ((_bits & 0x200000000000L) != 0) { - _bits |= 0x40000L; - _headers._LastModified = value; - return; + value = _headers._TraceState; + return true; } - if ("Authorization".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + + if (HeaderNames.Connection.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x2L) != 0) { - _bits |= 0x800000L; - _headers._Authorization = value; - return; + value = _headers._Connection; + return true; } - if ("If-None-Match".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (HeaderNames.UserAgent.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x8000000000L) != 0) { - _bits |= 0x40000000L; - _headers._IfNoneMatch = value; - return; + value = _headers._UserAgent; + return true; } + return false; } - break; - case 10: + if (HeaderNames.KeepAlive.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Connection".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x8L) != 0) { - _bits |= 0x2L; - _headers._Connection = value; - return; + value = _headers._KeepAlive; + return true; } - if ("Keep-Alive".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (HeaderNames.RequestId.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x40000000000L) != 0) { - _bits |= 0x8L; - _headers._KeepAlive = value; - return; + value = _headers._RequestId; + return true; } - if ("User-Agent".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (HeaderNames.TraceState.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x200000000000L) != 0) { - _bits |= 0x8000000000L; - _headers._UserAgent = value; - return; + value = _headers._TraceState; + return true; } + return false; } break; - case 4: + } + case 11: + { + if (ReferenceEquals(HeaderNames.ContentMD5, key)) { - if ("Date".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x8000L) != 0) { - _bits |= 0x4L; - _headers._Date = value; - return; + value = _headers._ContentMD5; + return true; } - if ("From".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (ReferenceEquals(HeaderNames.TraceParent, key)) + { + if ((_bits & 0x100000000000L) != 0) { - _bits |= 0x4000000L; - _headers._From = value; - return; + value = _headers._TraceParent; + return true; } - if ("Host".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + + if (HeaderNames.ContentMD5.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x8000L) != 0) { - _bits |= 0x8000000L; - _headers._Host = value; - return; + value = _headers._ContentMD5; + return true; } + return false; } - break; - case 6: + if (HeaderNames.TraceParent.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Pragma".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x100000000000L) != 0) { - _bits |= 0x10L; - _headers._Pragma = value; - return; + value = _headers._TraceParent; + return true; } - if ("Accept".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + break; + } + case 12: + { + if (ReferenceEquals(HeaderNames.ContentType, key)) + { + if ((_bits & 0x800L) != 0) { - _bits |= 0x80000L; - _headers._Accept = value; - return; + value = _headers._ContentType; + return true; } - if ("Cookie".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (ReferenceEquals(HeaderNames.MaxForwards, key)) + { + if ((_bits & 0x200000000L) != 0) { - _bits |= 0x1000000L; - _headers._Cookie = value; - return; + value = _headers._MaxForwards; + return true; } - if ("Expect".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + + if (HeaderNames.ContentType.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x800L) != 0) { - _bits |= 0x2000000L; - _headers._Expect = value; - return; + value = _headers._ContentType; + return true; } - if ("Origin".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (HeaderNames.MaxForwards.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x200000000L) != 0) { - _bits |= 0x40000000000L; - _headers._Origin = value; - return; + value = _headers._MaxForwards; + return true; } + return false; } break; - case 7: + } + case 13: + { + if (ReferenceEquals(HeaderNames.CacheControl, key)) { - if ("Trailer".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - _bits |= 0x20L; - _headers._Trailer = value; - return; - } - if ("Upgrade".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x1L) != 0) { - _bits |= 0x80L; - _headers._Upgrade = value; - return; + value = _headers._CacheControl; + return true; } - if ("Warning".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (ReferenceEquals(HeaderNames.ContentRange, key)) + { + if ((_bits & 0x10000L) != 0) { - _bits |= 0x200L; - _headers._Warning = value; - return; + value = _headers._ContentRange; + return true; } - if ("Expires".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (ReferenceEquals(HeaderNames.LastModified, key)) + { + if ((_bits & 0x40000L) != 0) { - _bits |= 0x20000L; - _headers._Expires = value; - return; + value = _headers._LastModified; + return true; } - if ("Referer".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (ReferenceEquals(HeaderNames.Authorization, key)) + { + if ((_bits & 0x800000L) != 0) { - _bits |= 0x800000000L; - _headers._Referer = value; - return; + value = _headers._Authorization; + return true; } + return false; } - break; - case 17: + if (ReferenceEquals(HeaderNames.IfNoneMatch, key)) { - if ("Transfer-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x40000000L) != 0) { - _bits |= 0x40L; - _headers._TransferEncoding = value; - return; + value = _headers._IfNoneMatch; + return true; } - if ("If-Modified-Since".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + + if (HeaderNames.CacheControl.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x1L) != 0) { - _bits |= 0x20000000L; - _headers._IfModifiedSince = value; - return; + value = _headers._CacheControl; + return true; } + return false; } - break; - case 3: + if (HeaderNames.ContentRange.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Via".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x10000L) != 0) { - _bits |= 0x100L; - _headers._Via = value; - return; + value = _headers._ContentRange; + return true; } - if ("DNT".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (HeaderNames.LastModified.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x40000L) != 0) { - _bits |= 0x10000000000L; - _headers._DNT = value; - return; + value = _headers._LastModified; + return true; } + return false; } - break; - case 5: + if (HeaderNames.Authorization.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Allow".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x800000L) != 0) { - _bits |= 0x400L; - _headers._Allow = value; - return; + value = _headers._Authorization; + return true; } - if ("Range".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (HeaderNames.IfNoneMatch.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x40000000L) != 0) { - _bits |= 0x1000000000L; - _headers._Range = value; - return; + value = _headers._IfNoneMatch; + return true; } + return false; } break; - case 12: + } + case 14: + { + if (ReferenceEquals(HeaderNames.AcceptCharset, key)) { - if ("Content-Type".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x100000L) != 0) { - _bits |= 0x800L; - _headers._ContentType = value; - return; + value = _headers._AcceptCharset; + return true; } - if ("Max-Forwards".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (ReferenceEquals(HeaderNames.ContentLength, key)) + { + if (_contentLength.HasValue) { - _bits |= 0x200000000L; - _headers._MaxForwards = value; - return; + value = HeaderUtilities.FormatNonNegativeInt64(_contentLength.Value); + return true; } + return false; } - break; - case 16: + + if (HeaderNames.AcceptCharset.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Content-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - _bits |= 0x1000L; - _headers._ContentEncoding = value; - return; - } - if ("Content-Language".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x100000L) != 0) { - _bits |= 0x2000L; - _headers._ContentLanguage = value; - return; - } - if ("Content-Location".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - _bits |= 0x4000L; - _headers._ContentLocation = value; - return; + value = _headers._AcceptCharset; + return true; } + return false; } - break; - case 11: + if (HeaderNames.ContentLength.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Content-MD5".Equals(key, StringComparison.OrdinalIgnoreCase)) + if (_contentLength.HasValue) { - _bits |= 0x8000L; - _headers._ContentMD5 = value; - return; + value = HeaderUtilities.FormatNonNegativeInt64(_contentLength.Value); + return true; } + return false; } break; - case 14: + } + case 15: + { + if (ReferenceEquals(HeaderNames.AcceptEncoding, key)) { - if ("Accept-Charset".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x200000L) != 0) { - _bits |= 0x100000L; - _headers._AcceptCharset = value; - return; + value = _headers._AcceptEncoding; + return true; } - if ("Content-Length".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (ReferenceEquals(HeaderNames.AcceptLanguage, key)) + { + if ((_bits & 0x400000L) != 0) { - _contentLength = ParseContentLength(value.ToString()); - return; + value = _headers._AcceptLanguage; + return true; } + return false; } - break; - case 15: + + if (HeaderNames.AcceptEncoding.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Accept-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x200000L) != 0) { - _bits |= 0x200000L; - _headers._AcceptEncoding = value; - return; + value = _headers._AcceptEncoding; + return true; } - if ("Accept-Language".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (HeaderNames.AcceptLanguage.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x400000L) != 0) { - _bits |= 0x400000L; - _headers._AcceptLanguage = value; - return; + value = _headers._AcceptLanguage; + return true; } + return false; } break; - case 8: + } + case 16: + { + if (ReferenceEquals(HeaderNames.ContentEncoding, key)) { - if ("If-Match".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - _bits |= 0x10000000L; - _headers._IfMatch = value; - return; - } - if ("If-Range".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x1000L) != 0) { - _bits |= 0x80000000L; - _headers._IfRange = value; - return; + value = _headers._ContentEncoding; + return true; } + return false; } - break; - case 19: + if (ReferenceEquals(HeaderNames.ContentLanguage, key)) { - if ("If-Unmodified-Since".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x2000L) != 0) { - _bits |= 0x100000000L; - _headers._IfUnmodifiedSince = value; - return; + value = _headers._ContentLanguage; + return true; } - if ("Proxy-Authorization".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (ReferenceEquals(HeaderNames.ContentLocation, key)) + { + if ((_bits & 0x4000L) != 0) { - _bits |= 0x400000000L; - _headers._ProxyAuthorization = value; - return; + value = _headers._ContentLocation; + return true; } + return false; } - break; - case 2: + + if (HeaderNames.ContentEncoding.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("TE".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x1000L) != 0) { - _bits |= 0x2000000000L; - _headers._TE = value; - return; + value = _headers._ContentEncoding; + return true; } + return false; } - break; - case 9: + if (HeaderNames.ContentLanguage.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Translate".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x2000L) != 0) { - _bits |= 0x4000000000L; - _headers._Translate = value; - return; + value = _headers._ContentLanguage; + return true; } + return false; } - break; - case 25: + if (HeaderNames.ContentLocation.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Upgrade-Insecure-Requests".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x4000L) != 0) { - _bits |= 0x20000000000L; - _headers._UpgradeInsecureRequests = value; - return; + value = _headers._ContentLocation; + return true; } + return false; } break; - case 29: + } + case 17: + { + if (ReferenceEquals(HeaderNames.TransferEncoding, key)) { - if ("Access-Control-Request-Method".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x40L) != 0) { - _bits |= 0x80000000000L; - _headers._AccessControlRequestMethod = value; - return; + value = _headers._TransferEncoding; + return true; } + return false; } - break; - case 30: + if (ReferenceEquals(HeaderNames.IfModifiedSince, key)) { - if ("Access-Control-Request-Headers".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x20000000L) != 0) { - _bits |= 0x100000000000L; - _headers._AccessControlRequestHeaders = value; - return; + value = _headers._IfModifiedSince; + return true; } + return false; } - break; - } - SetValueUnknown(key, value); - } - - protected override bool AddValueFast(string key, StringValues value) - { - switch (key.Length) - { - case 13: + if (HeaderNames.TransferEncoding.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Cache-Control".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x1L) == 0) - { - _bits |= 0x1L; - _headers._CacheControl = value; - return true; - } - return false; - } - if ("Content-Range".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x10000L) == 0) - { - _bits |= 0x10000L; - _headers._ContentRange = value; - return true; - } - return false; - } - if ("Last-Modified".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x40000L) == 0) - { - _bits |= 0x40000L; - _headers._LastModified = value; - return true; - } - return false; - } - if ("Authorization".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x40L) != 0) { - if ((_bits & 0x800000L) == 0) - { - _bits |= 0x800000L; - _headers._Authorization = value; - return true; - } - return false; - } - if ("If-None-Match".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x40000000L) == 0) - { - _bits |= 0x40000000L; - _headers._IfNoneMatch = value; - return true; - } - return false; + value = _headers._TransferEncoding; + return true; } + return false; } - break; - case 10: + if (HeaderNames.IfModifiedSince.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Connection".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x2L) == 0) - { - _bits |= 0x2L; - _headers._Connection = value; - return true; - } - return false; - } - if ("Keep-Alive".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x8L) == 0) - { - _bits |= 0x8L; - _headers._KeepAlive = value; - return true; - } - return false; - } - if ("User-Agent".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x20000000L) != 0) { - if ((_bits & 0x8000000000L) == 0) - { - _bits |= 0x8000000000L; - _headers._UserAgent = value; - return true; - } - return false; + value = _headers._IfModifiedSince; + return true; } + return false; } break; - case 4: + } + case 19: + { + if (ReferenceEquals(HeaderNames.IfUnmodifiedSince, key)) { - if ("Date".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x4L) == 0) - { - _bits |= 0x4L; - _headers._Date = value; - return true; - } - return false; - } - if ("From".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x4000000L) == 0) - { - _bits |= 0x4000000L; - _headers._From = value; - return true; - } - return false; - } - if ("Host".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x100000000L) != 0) { - if ((_bits & 0x8000000L) == 0) - { - _bits |= 0x8000000L; - _headers._Host = value; - return true; - } - return false; + value = _headers._IfUnmodifiedSince; + return true; } + return false; } - break; - case 6: + if (ReferenceEquals(HeaderNames.ProxyAuthorization, key)) { - if ("Pragma".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x10L) == 0) - { - _bits |= 0x10L; - _headers._Pragma = value; - return true; - } - return false; - } - if ("Accept".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x80000L) == 0) - { - _bits |= 0x80000L; - _headers._Accept = value; - return true; - } - return false; - } - if ("Cookie".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x1000000L) == 0) - { - _bits |= 0x1000000L; - _headers._Cookie = value; - return true; - } - return false; - } - if ("Expect".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x2000000L) == 0) - { - _bits |= 0x2000000L; - _headers._Expect = value; - return true; - } - return false; - } - if ("Origin".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x400000000L) != 0) { - if ((_bits & 0x40000000000L) == 0) - { - _bits |= 0x40000000000L; - _headers._Origin = value; - return true; - } - return false; + value = _headers._ProxyAuthorization; + return true; } + return false; } - break; - case 7: + if (ReferenceEquals(HeaderNames.CorrelationContext, key)) { - if ("Trailer".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x20L) == 0) - { - _bits |= 0x20L; - _headers._Trailer = value; - return true; - } - return false; - } - if ("Upgrade".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x80L) == 0) - { - _bits |= 0x80L; - _headers._Upgrade = value; - return true; - } - return false; - } - if ("Warning".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x200L) == 0) - { - _bits |= 0x200L; - _headers._Warning = value; - return true; - } - return false; - } - if ("Expires".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x80000000000L) != 0) { - if ((_bits & 0x20000L) == 0) - { - _bits |= 0x20000L; - _headers._Expires = value; - return true; - } - return false; + value = _headers._CorrelationContext; + return true; } - if ("Referer".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + + if (HeaderNames.IfUnmodifiedSince.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x100000000L) != 0) { - if ((_bits & 0x800000000L) == 0) - { - _bits |= 0x800000000L; - _headers._Referer = value; - return true; - } - return false; + value = _headers._IfUnmodifiedSince; + return true; } + return false; } - break; - case 17: + if (HeaderNames.ProxyAuthorization.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Transfer-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x400000000L) != 0) { - if ((_bits & 0x40L) == 0) - { - _bits |= 0x40L; - _headers._TransferEncoding = value; - return true; - } - return false; + value = _headers._ProxyAuthorization; + return true; } - if ("If-Modified-Since".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (HeaderNames.CorrelationContext.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x80000000000L) != 0) { - if ((_bits & 0x20000000L) == 0) - { - _bits |= 0x20000000L; - _headers._IfModifiedSince = value; - return true; - } - return false; + value = _headers._CorrelationContext; + return true; } + return false; } break; - case 3: + } + case 25: + { + if (ReferenceEquals(HeaderNames.UpgradeInsecureRequests, key)) { - if ("Via".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x20000000000L) != 0) { - if ((_bits & 0x100L) == 0) - { - _bits |= 0x100L; - _headers._Via = value; - return true; - } - return false; + value = _headers._UpgradeInsecureRequests; + return true; } - if ("DNT".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + + if (HeaderNames.UpgradeInsecureRequests.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x20000000000L) != 0) { - if ((_bits & 0x10000000000L) == 0) - { - _bits |= 0x10000000000L; - _headers._DNT = value; - return true; - } - return false; + value = _headers._UpgradeInsecureRequests; + return true; } + return false; } break; - case 5: + } + case 29: + { + if (ReferenceEquals(HeaderNames.AccessControlRequestMethod, key)) { - if ("Allow".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x800000000000L) != 0) { - if ((_bits & 0x400L) == 0) - { - _bits |= 0x400L; - _headers._Allow = value; - return true; - } - return false; + value = _headers._AccessControlRequestMethod; + return true; } - if ("Range".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + + if (HeaderNames.AccessControlRequestMethod.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x800000000000L) != 0) { - if ((_bits & 0x1000000000L) == 0) - { - _bits |= 0x1000000000L; - _headers._Range = value; - return true; - } - return false; + value = _headers._AccessControlRequestMethod; + return true; } + return false; } break; - case 12: + } + case 30: + { + if (ReferenceEquals(HeaderNames.AccessControlRequestHeaders, key)) { - if ("Content-Type".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x1000000000000L) != 0) { - if ((_bits & 0x800L) == 0) - { - _bits |= 0x800L; - _headers._ContentType = value; - return true; - } - return false; + value = _headers._AccessControlRequestHeaders; + return true; } - if ("Max-Forwards".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + + if (HeaderNames.AccessControlRequestHeaders.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x1000000000000L) != 0) { - if ((_bits & 0x200000000L) == 0) - { - _bits |= 0x200000000L; - _headers._MaxForwards = value; - return true; - } - return false; + value = _headers._AccessControlRequestHeaders; + return true; } + return false; } break; - case 16: + } + } + + return TryGetUnknown(key, ref value); + } + + protected override void SetValueFast(string key, StringValues value) + { + switch (key.Length) + { + case 2: + { + if (ReferenceEquals(HeaderNames.TE, key)) { - if ("Content-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x1000L) == 0) - { - _bits |= 0x1000L; - _headers._ContentEncoding = value; - return true; - } - return false; - } - if ("Content-Language".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x2000L) == 0) - { - _bits |= 0x2000L; - _headers._ContentLanguage = value; - return true; - } - return false; - } - if ("Content-Location".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x4000L) == 0) - { - _bits |= 0x4000L; - _headers._ContentLocation = value; - return true; - } - return false; - } + _bits |= 0x2000000000L; + _headers._TE = value; + return; } - break; - case 11: + + if (HeaderNames.TE.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Content-MD5".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x8000L) == 0) - { - _bits |= 0x8000L; - _headers._ContentMD5 = value; - return true; - } - return false; - } + _bits |= 0x2000000000L; + _headers._TE = value; + return; } break; - case 14: + } + case 3: + { + if (ReferenceEquals(HeaderNames.Via, key)) { - if ("Accept-Charset".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x100000L) == 0) - { - _bits |= 0x100000L; - _headers._AcceptCharset = value; - return true; - } - return false; - } - if ("Content-Length".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if (!_contentLength.HasValue) - { - _contentLength = ParseContentLength(value); - return true; - } - return false; - } + _bits |= 0x100L; + _headers._Via = value; + return; } - break; - case 15: + if (ReferenceEquals(HeaderNames.DNT, key)) { - if ("Accept-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x200000L) == 0) - { - _bits |= 0x200000L; - _headers._AcceptEncoding = value; - return true; - } - return false; - } - if ("Accept-Language".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x400000L) == 0) - { - _bits |= 0x400000L; - _headers._AcceptLanguage = value; - return true; - } - return false; - } + _bits |= 0x10000000000L; + _headers._DNT = value; + return; } - break; - case 8: + + if (HeaderNames.Via.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("If-Match".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x10000000L) == 0) - { - _bits |= 0x10000000L; - _headers._IfMatch = value; - return true; - } - return false; - } - if ("If-Range".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x80000000L) == 0) - { - _bits |= 0x80000000L; - _headers._IfRange = value; - return true; - } - return false; - } + _bits |= 0x100L; + _headers._Via = value; + return; } - break; - case 19: + if (HeaderNames.DNT.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("If-Unmodified-Since".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x100000000L) == 0) - { - _bits |= 0x100000000L; - _headers._IfUnmodifiedSince = value; - return true; - } - return false; - } - if ("Proxy-Authorization".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x400000000L) == 0) - { - _bits |= 0x400000000L; - _headers._ProxyAuthorization = value; - return true; - } - return false; - } + _bits |= 0x10000000000L; + _headers._DNT = value; + return; } break; - case 2: + } + case 4: + { + if (ReferenceEquals(HeaderNames.Host, key)) { - if ("TE".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x2000000000L) == 0) - { - _bits |= 0x2000000000L; - _headers._TE = value; - return true; - } - return false; - } + _bits |= 0x8000000L; + _headers._Host = value; + return; } - break; - case 9: + if (ReferenceEquals(HeaderNames.Date, key)) { - if ("Translate".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x4000000000L) == 0) - { - _bits |= 0x4000000000L; - _headers._Translate = value; - return true; - } - return false; - } + _bits |= 0x4L; + _headers._Date = value; + return; } - break; - case 25: + if (ReferenceEquals(HeaderNames.From, key)) { - if ("Upgrade-Insecure-Requests".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x20000000000L) == 0) - { - _bits |= 0x20000000000L; - _headers._UpgradeInsecureRequests = value; - return true; - } - return false; - } + _bits |= 0x4000000L; + _headers._From = value; + return; } - break; - case 29: + + if (HeaderNames.Host.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Access-Control-Request-Method".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x80000000000L) == 0) - { - _bits |= 0x80000000000L; - _headers._AccessControlRequestMethod = value; - return true; - } - return false; - } + _bits |= 0x8000000L; + _headers._Host = value; + return; } - break; - case 30: + if (HeaderNames.Date.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Access-Control-Request-Headers".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x100000000000L) == 0) - { - _bits |= 0x100000000000L; - _headers._AccessControlRequestHeaders = value; - return true; - } - return false; - } + _bits |= 0x4L; + _headers._Date = value; + return; } - break; - } - - Unknown.Add(key, value); - // Return true, above will throw and exit for false - return true; - } - - protected override bool RemoveFast(string key) - { - switch (key.Length) - { - case 13: + if (HeaderNames.From.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Cache-Control".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x1L) != 0) - { - _bits &= ~0x1L; - _headers._CacheControl = default(StringValues); - return true; - } - return false; - } - if ("Content-Range".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x10000L) != 0) - { - _bits &= ~0x10000L; - _headers._ContentRange = default(StringValues); - return true; - } - return false; - } - if ("Last-Modified".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x40000L) != 0) - { - _bits &= ~0x40000L; - _headers._LastModified = default(StringValues); - return true; - } - return false; - } - if ("Authorization".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x800000L) != 0) - { - _bits &= ~0x800000L; - _headers._Authorization = default(StringValues); - return true; - } - return false; - } - if ("If-None-Match".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x40000000L) != 0) - { - _bits &= ~0x40000000L; - _headers._IfNoneMatch = default(StringValues); - return true; - } - return false; - } + _bits |= 0x4000000L; + _headers._From = value; + return; } break; - case 10: + } + case 5: + { + if (ReferenceEquals(HeaderNames.Allow, key)) { - if ("Connection".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x2L) != 0) - { - _bits &= ~0x2L; - _headers._Connection = default(StringValues); - return true; - } - return false; - } - if ("Keep-Alive".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x8L) != 0) - { - _bits &= ~0x8L; - _headers._KeepAlive = default(StringValues); - return true; - } - return false; - } - if ("User-Agent".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x8000000000L) != 0) - { - _bits &= ~0x8000000000L; - _headers._UserAgent = default(StringValues); - return true; - } - return false; - } + _bits |= 0x400L; + _headers._Allow = value; + return; } - break; - case 4: + if (ReferenceEquals(HeaderNames.Range, key)) { - if ("Date".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x4L) != 0) - { - _bits &= ~0x4L; - _headers._Date = default(StringValues); - return true; - } - return false; - } - if ("From".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x4000000L) != 0) - { - _bits &= ~0x4000000L; - _headers._From = default(StringValues); - return true; - } - return false; - } - if ("Host".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x8000000L) != 0) - { - _bits &= ~0x8000000L; - _headers._Host = default(StringValues); - return true; - } - return false; - } + _bits |= 0x1000000000L; + _headers._Range = value; + return; } - break; - case 6: + + if (HeaderNames.Allow.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Pragma".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x10L) != 0) - { - _bits &= ~0x10L; - _headers._Pragma = default(StringValues); - return true; - } - return false; - } - if ("Accept".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x80000L) != 0) - { - _bits &= ~0x80000L; - _headers._Accept = default(StringValues); - return true; - } - return false; - } - if ("Cookie".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x1000000L) != 0) - { - _bits &= ~0x1000000L; - _headers._Cookie = default(StringValues); - return true; - } - return false; - } - if ("Expect".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x2000000L) != 0) - { - _bits &= ~0x2000000L; - _headers._Expect = default(StringValues); - return true; - } - return false; - } - if ("Origin".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x40000000000L) != 0) - { - _bits &= ~0x40000000000L; - _headers._Origin = default(StringValues); - return true; - } - return false; - } + _bits |= 0x400L; + _headers._Allow = value; + return; } - break; - case 7: + if (HeaderNames.Range.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Trailer".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x20L) != 0) - { - _bits &= ~0x20L; - _headers._Trailer = default(StringValues); - return true; - } - return false; - } - if ("Upgrade".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x80L) != 0) - { - _bits &= ~0x80L; - _headers._Upgrade = default(StringValues); - return true; - } - return false; - } - if ("Warning".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x200L) != 0) - { - _bits &= ~0x200L; - _headers._Warning = default(StringValues); - return true; - } - return false; - } - if ("Expires".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x20000L) != 0) - { - _bits &= ~0x20000L; - _headers._Expires = default(StringValues); - return true; - } - return false; - } - if ("Referer".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x800000000L) != 0) - { - _bits &= ~0x800000000L; - _headers._Referer = default(StringValues); - return true; - } - return false; - } + _bits |= 0x1000000000L; + _headers._Range = value; + return; } break; - case 17: + } + case 6: + { + if (ReferenceEquals(HeaderNames.Accept, key)) { - if ("Transfer-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x40L) != 0) - { - _bits &= ~0x40L; - _headers._TransferEncoding = default(StringValues); - return true; - } - return false; - } - if ("If-Modified-Since".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x20000000L) != 0) - { - _bits &= ~0x20000000L; - _headers._IfModifiedSince = default(StringValues); - return true; - } - return false; - } + _bits |= 0x80000L; + _headers._Accept = value; + return; } - break; - case 3: + if (ReferenceEquals(HeaderNames.Pragma, key)) { - if ("Via".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x100L) != 0) - { - _bits &= ~0x100L; - _headers._Via = default(StringValues); - return true; - } - return false; - } - if ("DNT".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x10000000000L) != 0) - { - _bits &= ~0x10000000000L; - _headers._DNT = default(StringValues); - return true; - } - return false; - } + _bits |= 0x10L; + _headers._Pragma = value; + return; } - break; - case 5: + if (ReferenceEquals(HeaderNames.Cookie, key)) { - if ("Allow".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x400L) != 0) - { - _bits &= ~0x400L; - _headers._Allow = default(StringValues); - return true; - } - return false; - } - if ("Range".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x1000000000L) != 0) - { - _bits &= ~0x1000000000L; - _headers._Range = default(StringValues); - return true; - } - return false; - } + _bits |= 0x1000000L; + _headers._Cookie = value; + return; } - break; - case 12: + if (ReferenceEquals(HeaderNames.Expect, key)) { - if ("Content-Type".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x800L) != 0) - { - _bits &= ~0x800L; - _headers._ContentType = default(StringValues); - return true; - } - return false; - } - if ("Max-Forwards".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x200000000L) != 0) - { - _bits &= ~0x200000000L; - _headers._MaxForwards = default(StringValues); - return true; - } - return false; - } + _bits |= 0x2000000L; + _headers._Expect = value; + return; } - break; - case 16: + if (ReferenceEquals(HeaderNames.Origin, key)) { - if ("Content-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x1000L) != 0) - { - _bits &= ~0x1000L; - _headers._ContentEncoding = default(StringValues); - return true; - } - return false; - } - if ("Content-Language".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x2000L) != 0) - { - _bits &= ~0x2000L; - _headers._ContentLanguage = default(StringValues); - return true; - } - return false; - } - if ("Content-Location".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x4000L) != 0) - { - _bits &= ~0x4000L; - _headers._ContentLocation = default(StringValues); - return true; - } - return false; - } + _bits |= 0x400000000000L; + _headers._Origin = value; + return; } - break; - case 11: + + if (HeaderNames.Accept.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Content-MD5".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x8000L) != 0) - { - _bits &= ~0x8000L; - _headers._ContentMD5 = default(StringValues); - return true; - } - return false; - } + _bits |= 0x80000L; + _headers._Accept = value; + return; } - break; - case 14: + if (HeaderNames.Pragma.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Accept-Charset".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x100000L) != 0) - { - _bits &= ~0x100000L; - _headers._AcceptCharset = default(StringValues); - return true; - } - return false; - } - if ("Content-Length".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if (_contentLength.HasValue) - { - _contentLength = null; - return true; - } - return false; - } + _bits |= 0x10L; + _headers._Pragma = value; + return; + } + if (HeaderNames.Cookie.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x1000000L; + _headers._Cookie = value; + return; + } + if (HeaderNames.Expect.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x2000000L; + _headers._Expect = value; + return; + } + if (HeaderNames.Origin.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x400000000000L; + _headers._Origin = value; + return; } break; - case 15: + } + case 7: + { + if (ReferenceEquals(HeaderNames.Trailer, key)) { - if ("Accept-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x200000L) != 0) - { - _bits &= ~0x200000L; - _headers._AcceptEncoding = default(StringValues); - return true; - } - return false; - } - if ("Accept-Language".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x400000L) != 0) - { - _bits &= ~0x400000L; - _headers._AcceptLanguage = default(StringValues); - return true; - } - return false; - } + _bits |= 0x20L; + _headers._Trailer = value; + return; + } + if (ReferenceEquals(HeaderNames.Upgrade, key)) + { + _bits |= 0x80L; + _headers._Upgrade = value; + return; + } + if (ReferenceEquals(HeaderNames.Warning, key)) + { + _bits |= 0x200L; + _headers._Warning = value; + return; + } + if (ReferenceEquals(HeaderNames.Expires, key)) + { + _bits |= 0x20000L; + _headers._Expires = value; + return; + } + if (ReferenceEquals(HeaderNames.Referer, key)) + { + _bits |= 0x800000000L; + _headers._Referer = value; + return; + } + + if (HeaderNames.Trailer.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x20L; + _headers._Trailer = value; + return; + } + if (HeaderNames.Upgrade.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x80L; + _headers._Upgrade = value; + return; + } + if (HeaderNames.Warning.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x200L; + _headers._Warning = value; + return; + } + if (HeaderNames.Expires.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x20000L; + _headers._Expires = value; + return; + } + if (HeaderNames.Referer.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x800000000L; + _headers._Referer = value; + return; } break; + } case 8: + { + if (ReferenceEquals(HeaderNames.IfMatch, key)) { - if ("If-Match".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x10000000L) != 0) - { - _bits &= ~0x10000000L; - _headers._IfMatch = default(StringValues); - return true; - } - return false; - } - if ("If-Range".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x80000000L) != 0) - { - _bits &= ~0x80000000L; - _headers._IfRange = default(StringValues); - return true; - } - return false; - } + _bits |= 0x10000000L; + _headers._IfMatch = value; + return; } - break; - case 19: + if (ReferenceEquals(HeaderNames.IfRange, key)) { - if ("If-Unmodified-Since".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x100000000L) != 0) - { - _bits &= ~0x100000000L; - _headers._IfUnmodifiedSince = default(StringValues); - return true; - } - return false; - } - if ("Proxy-Authorization".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x400000000L) != 0) - { - _bits &= ~0x400000000L; - _headers._ProxyAuthorization = default(StringValues); - return true; - } - return false; - } + _bits |= 0x80000000L; + _headers._IfRange = value; + return; } - break; - case 2: + + if (HeaderNames.IfMatch.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("TE".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x2000000000L) != 0) - { - _bits &= ~0x2000000000L; - _headers._TE = default(StringValues); - return true; - } - return false; - } + _bits |= 0x10000000L; + _headers._IfMatch = value; + return; + } + if (HeaderNames.IfRange.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x80000000L; + _headers._IfRange = value; + return; } break; + } case 9: + { + if (ReferenceEquals(HeaderNames.Translate, key)) { - if ("Translate".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x4000000000L) != 0) - { - _bits &= ~0x4000000000L; - _headers._Translate = default(StringValues); - return true; - } - return false; - } + _bits |= 0x4000000000L; + _headers._Translate = value; + return; } - break; - case 25: + + if (HeaderNames.Translate.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Upgrade-Insecure-Requests".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x20000000000L) != 0) - { - _bits &= ~0x20000000000L; - _headers._UpgradeInsecureRequests = default(StringValues); - return true; - } - return false; - } + _bits |= 0x4000000000L; + _headers._Translate = value; + return; } break; - case 29: + } + case 10: + { + if (ReferenceEquals(HeaderNames.Connection, key)) { - if ("Access-Control-Request-Method".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x80000000000L) != 0) - { - _bits &= ~0x80000000000L; - _headers._AccessControlRequestMethod = default(StringValues); - return true; - } - return false; - } + _bits |= 0x2L; + _headers._Connection = value; + return; } - break; - case 30: + if (ReferenceEquals(HeaderNames.UserAgent, key)) { - if ("Access-Control-Request-Headers".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x100000000000L) != 0) - { - _bits &= ~0x100000000000L; - _headers._AccessControlRequestHeaders = default(StringValues); - return true; - } - return false; - } + _bits |= 0x8000000000L; + _headers._UserAgent = value; + return; + } + if (ReferenceEquals(HeaderNames.KeepAlive, key)) + { + _bits |= 0x8L; + _headers._KeepAlive = value; + return; + } + if (ReferenceEquals(HeaderNames.RequestId, key)) + { + _bits |= 0x40000000000L; + _headers._RequestId = value; + return; + } + if (ReferenceEquals(HeaderNames.TraceState, key)) + { + _bits |= 0x200000000000L; + _headers._TraceState = value; + return; } - break; - } - return MaybeUnknown?.Remove(key) ?? false; - } - private void Clear(long bitsToClear) - { - var tempBits = bitsToClear; - - if ((tempBits & 0x2L) != 0) - { - _headers._Connection = default(StringValues); - if((tempBits & ~0x2L) == 0) - { - return; + if (HeaderNames.Connection.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x2L; + _headers._Connection = value; + return; + } + if (HeaderNames.UserAgent.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x8000000000L; + _headers._UserAgent = value; + return; + } + if (HeaderNames.KeepAlive.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x8L; + _headers._KeepAlive = value; + return; + } + if (HeaderNames.RequestId.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x40000000000L; + _headers._RequestId = value; + return; + } + if (HeaderNames.TraceState.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x200000000000L; + _headers._TraceState = value; + return; + } + break; } - tempBits &= ~0x2L; - } - - if ((tempBits & 0x80000L) != 0) - { - _headers._Accept = default(StringValues); - if((tempBits & ~0x80000L) == 0) + case 11: { - return; + if (ReferenceEquals(HeaderNames.ContentMD5, key)) + { + _bits |= 0x8000L; + _headers._ContentMD5 = value; + return; + } + if (ReferenceEquals(HeaderNames.TraceParent, key)) + { + _bits |= 0x100000000000L; + _headers._TraceParent = value; + return; + } + + if (HeaderNames.ContentMD5.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x8000L; + _headers._ContentMD5 = value; + return; + } + if (HeaderNames.TraceParent.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x100000000000L; + _headers._TraceParent = value; + return; + } + break; } - tempBits &= ~0x80000L; - } - - if ((tempBits & 0x8000000L) != 0) - { - _headers._Host = default(StringValues); - if((tempBits & ~0x8000000L) == 0) + case 12: { - return; + if (ReferenceEquals(HeaderNames.ContentType, key)) + { + _bits |= 0x800L; + _headers._ContentType = value; + return; + } + if (ReferenceEquals(HeaderNames.MaxForwards, key)) + { + _bits |= 0x200000000L; + _headers._MaxForwards = value; + return; + } + + if (HeaderNames.ContentType.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x800L; + _headers._ContentType = value; + return; + } + if (HeaderNames.MaxForwards.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x200000000L; + _headers._MaxForwards = value; + return; + } + break; } - tempBits &= ~0x8000000L; - } - - if ((tempBits & 0x8000000000L) != 0) - { - _headers._UserAgent = default(StringValues); - if((tempBits & ~0x8000000000L) == 0) + case 13: { - return; - } - tempBits &= ~0x8000000000L; - } - - if ((tempBits & 0x1L) != 0) - { - _headers._CacheControl = default(StringValues); - if((tempBits & ~0x1L) == 0) - { - return; - } - tempBits &= ~0x1L; - } - - if ((tempBits & 0x4L) != 0) - { - _headers._Date = default(StringValues); - if((tempBits & ~0x4L) == 0) - { - return; + if (ReferenceEquals(HeaderNames.CacheControl, key)) + { + _bits |= 0x1L; + _headers._CacheControl = value; + return; + } + if (ReferenceEquals(HeaderNames.ContentRange, key)) + { + _bits |= 0x10000L; + _headers._ContentRange = value; + return; + } + if (ReferenceEquals(HeaderNames.LastModified, key)) + { + _bits |= 0x40000L; + _headers._LastModified = value; + return; + } + if (ReferenceEquals(HeaderNames.Authorization, key)) + { + _bits |= 0x800000L; + _headers._Authorization = value; + return; + } + if (ReferenceEquals(HeaderNames.IfNoneMatch, key)) + { + _bits |= 0x40000000L; + _headers._IfNoneMatch = value; + return; + } + + if (HeaderNames.CacheControl.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x1L; + _headers._CacheControl = value; + return; + } + if (HeaderNames.ContentRange.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x10000L; + _headers._ContentRange = value; + return; + } + if (HeaderNames.LastModified.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x40000L; + _headers._LastModified = value; + return; + } + if (HeaderNames.Authorization.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x800000L; + _headers._Authorization = value; + return; + } + if (HeaderNames.IfNoneMatch.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x40000000L; + _headers._IfNoneMatch = value; + return; + } + break; } - tempBits &= ~0x4L; - } - - if ((tempBits & 0x8L) != 0) - { - _headers._KeepAlive = default(StringValues); - if((tempBits & ~0x8L) == 0) + case 14: { - return; + if (ReferenceEquals(HeaderNames.AcceptCharset, key)) + { + _bits |= 0x100000L; + _headers._AcceptCharset = value; + return; + } + if (ReferenceEquals(HeaderNames.ContentLength, key)) + { + _contentLength = ParseContentLength(value.ToString()); + return; + } + + if (HeaderNames.AcceptCharset.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x100000L; + _headers._AcceptCharset = value; + return; + } + if (HeaderNames.ContentLength.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _contentLength = ParseContentLength(value.ToString()); + return; + } + break; } - tempBits &= ~0x8L; - } - - if ((tempBits & 0x10L) != 0) - { - _headers._Pragma = default(StringValues); - if((tempBits & ~0x10L) == 0) + case 15: { - return; + if (ReferenceEquals(HeaderNames.AcceptEncoding, key)) + { + _bits |= 0x200000L; + _headers._AcceptEncoding = value; + return; + } + if (ReferenceEquals(HeaderNames.AcceptLanguage, key)) + { + _bits |= 0x400000L; + _headers._AcceptLanguage = value; + return; + } + + if (HeaderNames.AcceptEncoding.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x200000L; + _headers._AcceptEncoding = value; + return; + } + if (HeaderNames.AcceptLanguage.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x400000L; + _headers._AcceptLanguage = value; + return; + } + break; } - tempBits &= ~0x10L; - } - - if ((tempBits & 0x20L) != 0) - { - _headers._Trailer = default(StringValues); - if((tempBits & ~0x20L) == 0) + case 16: { - return; + if (ReferenceEquals(HeaderNames.ContentEncoding, key)) + { + _bits |= 0x1000L; + _headers._ContentEncoding = value; + return; + } + if (ReferenceEquals(HeaderNames.ContentLanguage, key)) + { + _bits |= 0x2000L; + _headers._ContentLanguage = value; + return; + } + if (ReferenceEquals(HeaderNames.ContentLocation, key)) + { + _bits |= 0x4000L; + _headers._ContentLocation = value; + return; + } + + if (HeaderNames.ContentEncoding.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x1000L; + _headers._ContentEncoding = value; + return; + } + if (HeaderNames.ContentLanguage.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x2000L; + _headers._ContentLanguage = value; + return; + } + if (HeaderNames.ContentLocation.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x4000L; + _headers._ContentLocation = value; + return; + } + break; } - tempBits &= ~0x20L; - } - - if ((tempBits & 0x40L) != 0) - { - _headers._TransferEncoding = default(StringValues); - if((tempBits & ~0x40L) == 0) + case 17: { - return; + if (ReferenceEquals(HeaderNames.TransferEncoding, key)) + { + _bits |= 0x40L; + _headers._TransferEncoding = value; + return; + } + if (ReferenceEquals(HeaderNames.IfModifiedSince, key)) + { + _bits |= 0x20000000L; + _headers._IfModifiedSince = value; + return; + } + + if (HeaderNames.TransferEncoding.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x40L; + _headers._TransferEncoding = value; + return; + } + if (HeaderNames.IfModifiedSince.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x20000000L; + _headers._IfModifiedSince = value; + return; + } + break; } - tempBits &= ~0x40L; - } - - if ((tempBits & 0x80L) != 0) - { - _headers._Upgrade = default(StringValues); - if((tempBits & ~0x80L) == 0) + case 19: { - return; + if (ReferenceEquals(HeaderNames.IfUnmodifiedSince, key)) + { + _bits |= 0x100000000L; + _headers._IfUnmodifiedSince = value; + return; + } + if (ReferenceEquals(HeaderNames.ProxyAuthorization, key)) + { + _bits |= 0x400000000L; + _headers._ProxyAuthorization = value; + return; + } + if (ReferenceEquals(HeaderNames.CorrelationContext, key)) + { + _bits |= 0x80000000000L; + _headers._CorrelationContext = value; + return; + } + + if (HeaderNames.IfUnmodifiedSince.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x100000000L; + _headers._IfUnmodifiedSince = value; + return; + } + if (HeaderNames.ProxyAuthorization.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x400000000L; + _headers._ProxyAuthorization = value; + return; + } + if (HeaderNames.CorrelationContext.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x80000000000L; + _headers._CorrelationContext = value; + return; + } + break; } - tempBits &= ~0x80L; - } - - if ((tempBits & 0x100L) != 0) - { - _headers._Via = default(StringValues); - if((tempBits & ~0x100L) == 0) + case 25: { - return; + if (ReferenceEquals(HeaderNames.UpgradeInsecureRequests, key)) + { + _bits |= 0x20000000000L; + _headers._UpgradeInsecureRequests = value; + return; + } + + if (HeaderNames.UpgradeInsecureRequests.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x20000000000L; + _headers._UpgradeInsecureRequests = value; + return; + } + break; } - tempBits &= ~0x100L; - } - - if ((tempBits & 0x200L) != 0) - { - _headers._Warning = default(StringValues); - if((tempBits & ~0x200L) == 0) + case 29: { - return; + if (ReferenceEquals(HeaderNames.AccessControlRequestMethod, key)) + { + _bits |= 0x800000000000L; + _headers._AccessControlRequestMethod = value; + return; + } + + if (HeaderNames.AccessControlRequestMethod.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x800000000000L; + _headers._AccessControlRequestMethod = value; + return; + } + break; } - tempBits &= ~0x200L; - } - - if ((tempBits & 0x400L) != 0) - { - _headers._Allow = default(StringValues); - if((tempBits & ~0x400L) == 0) + case 30: { - return; + if (ReferenceEquals(HeaderNames.AccessControlRequestHeaders, key)) + { + _bits |= 0x1000000000000L; + _headers._AccessControlRequestHeaders = value; + return; + } + + if (HeaderNames.AccessControlRequestHeaders.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x1000000000000L; + _headers._AccessControlRequestHeaders = value; + return; + } + break; } - tempBits &= ~0x400L; } - - if ((tempBits & 0x800L) != 0) + + SetValueUnknown(key, value); + } + + protected override bool AddValueFast(string key, StringValues value) + { + switch (key.Length) { - _headers._ContentType = default(StringValues); - if((tempBits & ~0x800L) == 0) + case 2: { - return; + if (ReferenceEquals(HeaderNames.TE, key)) + { + if ((_bits & 0x2000000000L) == 0) + { + _bits |= 0x2000000000L; + _headers._TE = value; + return true; + } + return false; + } + + if (HeaderNames.TE.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x2000000000L) == 0) + { + _bits |= 0x2000000000L; + _headers._TE = value; + return true; + } + return false; + } + break; } - tempBits &= ~0x800L; - } - - if ((tempBits & 0x1000L) != 0) - { - _headers._ContentEncoding = default(StringValues); - if((tempBits & ~0x1000L) == 0) + case 3: { - return; - } - tempBits &= ~0x1000L; - } - - if ((tempBits & 0x2000L) != 0) - { - _headers._ContentLanguage = default(StringValues); - if((tempBits & ~0x2000L) == 0) - { - return; - } - tempBits &= ~0x2000L; - } - - if ((tempBits & 0x4000L) != 0) - { - _headers._ContentLocation = default(StringValues); - if((tempBits & ~0x4000L) == 0) - { - return; - } - tempBits &= ~0x4000L; - } - - if ((tempBits & 0x8000L) != 0) - { - _headers._ContentMD5 = default(StringValues); - if((tempBits & ~0x8000L) == 0) - { - return; - } - tempBits &= ~0x8000L; - } - - if ((tempBits & 0x10000L) != 0) - { - _headers._ContentRange = default(StringValues); - if((tempBits & ~0x10000L) == 0) - { - return; - } - tempBits &= ~0x10000L; - } - - if ((tempBits & 0x20000L) != 0) - { - _headers._Expires = default(StringValues); - if((tempBits & ~0x20000L) == 0) - { - return; - } - tempBits &= ~0x20000L; - } - - if ((tempBits & 0x40000L) != 0) - { - _headers._LastModified = default(StringValues); - if((tempBits & ~0x40000L) == 0) - { - return; + if (ReferenceEquals(HeaderNames.Via, key)) + { + if ((_bits & 0x100L) == 0) + { + _bits |= 0x100L; + _headers._Via = value; + return true; + } + return false; + } + if (ReferenceEquals(HeaderNames.DNT, key)) + { + if ((_bits & 0x10000000000L) == 0) + { + _bits |= 0x10000000000L; + _headers._DNT = value; + return true; + } + return false; + } + + if (HeaderNames.Via.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x100L) == 0) + { + _bits |= 0x100L; + _headers._Via = value; + return true; + } + return false; + } + if (HeaderNames.DNT.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x10000000000L) == 0) + { + _bits |= 0x10000000000L; + _headers._DNT = value; + return true; + } + return false; + } + break; } - tempBits &= ~0x40000L; - } - - if ((tempBits & 0x100000L) != 0) - { - _headers._AcceptCharset = default(StringValues); - if((tempBits & ~0x100000L) == 0) + case 4: { - return; + if (ReferenceEquals(HeaderNames.Host, key)) + { + if ((_bits & 0x8000000L) == 0) + { + _bits |= 0x8000000L; + _headers._Host = value; + return true; + } + return false; + } + if (ReferenceEquals(HeaderNames.Date, key)) + { + if ((_bits & 0x4L) == 0) + { + _bits |= 0x4L; + _headers._Date = value; + return true; + } + return false; + } + if (ReferenceEquals(HeaderNames.From, key)) + { + if ((_bits & 0x4000000L) == 0) + { + _bits |= 0x4000000L; + _headers._From = value; + return true; + } + return false; + } + + if (HeaderNames.Host.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x8000000L) == 0) + { + _bits |= 0x8000000L; + _headers._Host = value; + return true; + } + return false; + } + if (HeaderNames.Date.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x4L) == 0) + { + _bits |= 0x4L; + _headers._Date = value; + return true; + } + return false; + } + if (HeaderNames.From.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x4000000L) == 0) + { + _bits |= 0x4000000L; + _headers._From = value; + return true; + } + return false; + } + break; } - tempBits &= ~0x100000L; - } - - if ((tempBits & 0x200000L) != 0) - { - _headers._AcceptEncoding = default(StringValues); - if((tempBits & ~0x200000L) == 0) + case 5: { - return; + if (ReferenceEquals(HeaderNames.Allow, key)) + { + if ((_bits & 0x400L) == 0) + { + _bits |= 0x400L; + _headers._Allow = value; + return true; + } + return false; + } + if (ReferenceEquals(HeaderNames.Range, key)) + { + if ((_bits & 0x1000000000L) == 0) + { + _bits |= 0x1000000000L; + _headers._Range = value; + return true; + } + return false; + } + + if (HeaderNames.Allow.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x400L) == 0) + { + _bits |= 0x400L; + _headers._Allow = value; + return true; + } + return false; + } + if (HeaderNames.Range.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x1000000000L) == 0) + { + _bits |= 0x1000000000L; + _headers._Range = value; + return true; + } + return false; + } + break; } - tempBits &= ~0x200000L; - } - - if ((tempBits & 0x400000L) != 0) - { - _headers._AcceptLanguage = default(StringValues); - if((tempBits & ~0x400000L) == 0) + case 6: { - return; + if (ReferenceEquals(HeaderNames.Accept, key)) + { + if ((_bits & 0x80000L) == 0) + { + _bits |= 0x80000L; + _headers._Accept = value; + return true; + } + return false; + } + if (ReferenceEquals(HeaderNames.Pragma, key)) + { + if ((_bits & 0x10L) == 0) + { + _bits |= 0x10L; + _headers._Pragma = value; + return true; + } + return false; + } + if (ReferenceEquals(HeaderNames.Cookie, key)) + { + if ((_bits & 0x1000000L) == 0) + { + _bits |= 0x1000000L; + _headers._Cookie = value; + return true; + } + return false; + } + if (ReferenceEquals(HeaderNames.Expect, key)) + { + if ((_bits & 0x2000000L) == 0) + { + _bits |= 0x2000000L; + _headers._Expect = value; + return true; + } + return false; + } + if (ReferenceEquals(HeaderNames.Origin, key)) + { + if ((_bits & 0x400000000000L) == 0) + { + _bits |= 0x400000000000L; + _headers._Origin = value; + return true; + } + return false; + } + + if (HeaderNames.Accept.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x80000L) == 0) + { + _bits |= 0x80000L; + _headers._Accept = value; + return true; + } + return false; + } + if (HeaderNames.Pragma.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x10L) == 0) + { + _bits |= 0x10L; + _headers._Pragma = value; + return true; + } + return false; + } + if (HeaderNames.Cookie.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x1000000L) == 0) + { + _bits |= 0x1000000L; + _headers._Cookie = value; + return true; + } + return false; + } + if (HeaderNames.Expect.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x2000000L) == 0) + { + _bits |= 0x2000000L; + _headers._Expect = value; + return true; + } + return false; + } + if (HeaderNames.Origin.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x400000000000L) == 0) + { + _bits |= 0x400000000000L; + _headers._Origin = value; + return true; + } + return false; + } + break; } - tempBits &= ~0x400000L; - } - - if ((tempBits & 0x800000L) != 0) - { - _headers._Authorization = default(StringValues); - if((tempBits & ~0x800000L) == 0) + case 7: { - return; - } - tempBits &= ~0x800000L; - } - - if ((tempBits & 0x1000000L) != 0) - { - _headers._Cookie = default(StringValues); - if((tempBits & ~0x1000000L) == 0) - { - return; - } - tempBits &= ~0x1000000L; - } - - if ((tempBits & 0x2000000L) != 0) - { - _headers._Expect = default(StringValues); - if((tempBits & ~0x2000000L) == 0) - { - return; - } - tempBits &= ~0x2000000L; - } - - if ((tempBits & 0x4000000L) != 0) - { - _headers._From = default(StringValues); - if((tempBits & ~0x4000000L) == 0) - { - return; - } - tempBits &= ~0x4000000L; - } - - if ((tempBits & 0x10000000L) != 0) - { - _headers._IfMatch = default(StringValues); - if((tempBits & ~0x10000000L) == 0) - { - return; - } - tempBits &= ~0x10000000L; - } - - if ((tempBits & 0x20000000L) != 0) - { - _headers._IfModifiedSince = default(StringValues); - if((tempBits & ~0x20000000L) == 0) - { - return; - } - tempBits &= ~0x20000000L; - } - - if ((tempBits & 0x40000000L) != 0) - { - _headers._IfNoneMatch = default(StringValues); - if((tempBits & ~0x40000000L) == 0) - { - return; - } - tempBits &= ~0x40000000L; - } - - if ((tempBits & 0x80000000L) != 0) - { - _headers._IfRange = default(StringValues); - if((tempBits & ~0x80000000L) == 0) - { - return; - } - tempBits &= ~0x80000000L; - } - - if ((tempBits & 0x100000000L) != 0) - { - _headers._IfUnmodifiedSince = default(StringValues); - if((tempBits & ~0x100000000L) == 0) - { - return; - } - tempBits &= ~0x100000000L; - } - - if ((tempBits & 0x200000000L) != 0) - { - _headers._MaxForwards = default(StringValues); - if((tempBits & ~0x200000000L) == 0) - { - return; - } - tempBits &= ~0x200000000L; - } - - if ((tempBits & 0x400000000L) != 0) - { - _headers._ProxyAuthorization = default(StringValues); - if((tempBits & ~0x400000000L) == 0) - { - return; - } - tempBits &= ~0x400000000L; - } - - if ((tempBits & 0x800000000L) != 0) - { - _headers._Referer = default(StringValues); - if((tempBits & ~0x800000000L) == 0) - { - return; - } - tempBits &= ~0x800000000L; - } - - if ((tempBits & 0x1000000000L) != 0) - { - _headers._Range = default(StringValues); - if((tempBits & ~0x1000000000L) == 0) - { - return; - } - tempBits &= ~0x1000000000L; - } - - if ((tempBits & 0x2000000000L) != 0) - { - _headers._TE = default(StringValues); - if((tempBits & ~0x2000000000L) == 0) - { - return; - } - tempBits &= ~0x2000000000L; - } - - if ((tempBits & 0x4000000000L) != 0) - { - _headers._Translate = default(StringValues); - if((tempBits & ~0x4000000000L) == 0) - { - return; - } - tempBits &= ~0x4000000000L; - } - - if ((tempBits & 0x10000000000L) != 0) - { - _headers._DNT = default(StringValues); - if((tempBits & ~0x10000000000L) == 0) - { - return; - } - tempBits &= ~0x10000000000L; - } - - if ((tempBits & 0x20000000000L) != 0) - { - _headers._UpgradeInsecureRequests = default(StringValues); - if((tempBits & ~0x20000000000L) == 0) - { - return; - } - tempBits &= ~0x20000000000L; - } - - if ((tempBits & 0x40000000000L) != 0) - { - _headers._Origin = default(StringValues); - if((tempBits & ~0x40000000000L) == 0) - { - return; - } - tempBits &= ~0x40000000000L; - } - - if ((tempBits & 0x80000000000L) != 0) - { - _headers._AccessControlRequestMethod = default(StringValues); - if((tempBits & ~0x80000000000L) == 0) - { - return; - } - tempBits &= ~0x80000000000L; - } - - if ((tempBits & 0x100000000000L) != 0) - { - _headers._AccessControlRequestHeaders = default(StringValues); - if((tempBits & ~0x100000000000L) == 0) - { - return; - } - tempBits &= ~0x100000000000L; - } - - } - - protected override bool CopyToFast(KeyValuePair[] array, int arrayIndex) - { - if (arrayIndex < 0) - { - return false; - } - - if ((_bits & 0x1L) != 0) - { - if (arrayIndex == array.Length) + if (ReferenceEquals(HeaderNames.Trailer, key)) { + if ((_bits & 0x20L) == 0) + { + _bits |= 0x20L; + _headers._Trailer = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("Cache-Control", _headers._CacheControl); - ++arrayIndex; - } - if ((_bits & 0x2L) != 0) - { - if (arrayIndex == array.Length) + if (ReferenceEquals(HeaderNames.Upgrade, key)) { + if ((_bits & 0x80L) == 0) + { + _bits |= 0x80L; + _headers._Upgrade = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("Connection", _headers._Connection); - ++arrayIndex; - } - if ((_bits & 0x4L) != 0) - { - if (arrayIndex == array.Length) + if (ReferenceEquals(HeaderNames.Warning, key)) { + if ((_bits & 0x200L) == 0) + { + _bits |= 0x200L; + _headers._Warning = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("Date", _headers._Date); - ++arrayIndex; - } - if ((_bits & 0x8L) != 0) - { - if (arrayIndex == array.Length) + if (ReferenceEquals(HeaderNames.Expires, key)) { + if ((_bits & 0x20000L) == 0) + { + _bits |= 0x20000L; + _headers._Expires = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("Keep-Alive", _headers._KeepAlive); - ++arrayIndex; - } - if ((_bits & 0x10L) != 0) - { - if (arrayIndex == array.Length) + if (ReferenceEquals(HeaderNames.Referer, key)) { + if ((_bits & 0x800000000L) == 0) + { + _bits |= 0x800000000L; + _headers._Referer = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("Pragma", _headers._Pragma); - ++arrayIndex; - } - if ((_bits & 0x20L) != 0) - { - if (arrayIndex == array.Length) + + if (HeaderNames.Trailer.Equals(key, StringComparison.OrdinalIgnoreCase)) { + if ((_bits & 0x20L) == 0) + { + _bits |= 0x20L; + _headers._Trailer = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("Trailer", _headers._Trailer); - ++arrayIndex; - } - if ((_bits & 0x40L) != 0) - { - if (arrayIndex == array.Length) + if (HeaderNames.Upgrade.Equals(key, StringComparison.OrdinalIgnoreCase)) { + if ((_bits & 0x80L) == 0) + { + _bits |= 0x80L; + _headers._Upgrade = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("Transfer-Encoding", _headers._TransferEncoding); - ++arrayIndex; - } - if ((_bits & 0x80L) != 0) - { - if (arrayIndex == array.Length) + if (HeaderNames.Warning.Equals(key, StringComparison.OrdinalIgnoreCase)) { + if ((_bits & 0x200L) == 0) + { + _bits |= 0x200L; + _headers._Warning = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("Upgrade", _headers._Upgrade); - ++arrayIndex; - } - if ((_bits & 0x100L) != 0) - { - if (arrayIndex == array.Length) + if (HeaderNames.Expires.Equals(key, StringComparison.OrdinalIgnoreCase)) { + if ((_bits & 0x20000L) == 0) + { + _bits |= 0x20000L; + _headers._Expires = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("Via", _headers._Via); - ++arrayIndex; - } - if ((_bits & 0x200L) != 0) - { - if (arrayIndex == array.Length) + if (HeaderNames.Referer.Equals(key, StringComparison.OrdinalIgnoreCase)) { + if ((_bits & 0x800000000L) == 0) + { + _bits |= 0x800000000L; + _headers._Referer = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("Warning", _headers._Warning); - ++arrayIndex; + break; } - if ((_bits & 0x400L) != 0) + case 8: { - if (arrayIndex == array.Length) + if (ReferenceEquals(HeaderNames.IfMatch, key)) { + if ((_bits & 0x10000000L) == 0) + { + _bits |= 0x10000000L; + _headers._IfMatch = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("Allow", _headers._Allow); - ++arrayIndex; - } - if ((_bits & 0x800L) != 0) - { - if (arrayIndex == array.Length) + if (ReferenceEquals(HeaderNames.IfRange, key)) { + if ((_bits & 0x80000000L) == 0) + { + _bits |= 0x80000000L; + _headers._IfRange = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("Content-Type", _headers._ContentType); - ++arrayIndex; - } - if ((_bits & 0x1000L) != 0) - { - if (arrayIndex == array.Length) + + if (HeaderNames.IfMatch.Equals(key, StringComparison.OrdinalIgnoreCase)) { + if ((_bits & 0x10000000L) == 0) + { + _bits |= 0x10000000L; + _headers._IfMatch = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("Content-Encoding", _headers._ContentEncoding); - ++arrayIndex; - } - if ((_bits & 0x2000L) != 0) - { - if (arrayIndex == array.Length) + if (HeaderNames.IfRange.Equals(key, StringComparison.OrdinalIgnoreCase)) { + if ((_bits & 0x80000000L) == 0) + { + _bits |= 0x80000000L; + _headers._IfRange = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("Content-Language", _headers._ContentLanguage); - ++arrayIndex; + break; } - if ((_bits & 0x4000L) != 0) + case 9: { - if (arrayIndex == array.Length) + if (ReferenceEquals(HeaderNames.Translate, key)) { + if ((_bits & 0x4000000000L) == 0) + { + _bits |= 0x4000000000L; + _headers._Translate = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("Content-Location", _headers._ContentLocation); - ++arrayIndex; - } - if ((_bits & 0x8000L) != 0) - { - if (arrayIndex == array.Length) + + if (HeaderNames.Translate.Equals(key, StringComparison.OrdinalIgnoreCase)) { + if ((_bits & 0x4000000000L) == 0) + { + _bits |= 0x4000000000L; + _headers._Translate = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("Content-MD5", _headers._ContentMD5); - ++arrayIndex; + break; } - if ((_bits & 0x10000L) != 0) + case 10: { - if (arrayIndex == array.Length) + if (ReferenceEquals(HeaderNames.Connection, key)) { + if ((_bits & 0x2L) == 0) + { + _bits |= 0x2L; + _headers._Connection = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("Content-Range", _headers._ContentRange); - ++arrayIndex; - } - if ((_bits & 0x20000L) != 0) - { - if (arrayIndex == array.Length) + if (ReferenceEquals(HeaderNames.UserAgent, key)) { + if ((_bits & 0x8000000000L) == 0) + { + _bits |= 0x8000000000L; + _headers._UserAgent = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("Expires", _headers._Expires); - ++arrayIndex; - } - if ((_bits & 0x40000L) != 0) - { - if (arrayIndex == array.Length) + if (ReferenceEquals(HeaderNames.KeepAlive, key)) { + if ((_bits & 0x8L) == 0) + { + _bits |= 0x8L; + _headers._KeepAlive = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("Last-Modified", _headers._LastModified); - ++arrayIndex; - } - if ((_bits & 0x80000L) != 0) - { - if (arrayIndex == array.Length) + if (ReferenceEquals(HeaderNames.RequestId, key)) { + if ((_bits & 0x40000000000L) == 0) + { + _bits |= 0x40000000000L; + _headers._RequestId = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("Accept", _headers._Accept); - ++arrayIndex; - } - if ((_bits & 0x100000L) != 0) - { - if (arrayIndex == array.Length) + if (ReferenceEquals(HeaderNames.TraceState, key)) { + if ((_bits & 0x200000000000L) == 0) + { + _bits |= 0x200000000000L; + _headers._TraceState = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("Accept-Charset", _headers._AcceptCharset); - ++arrayIndex; - } - if ((_bits & 0x200000L) != 0) - { - if (arrayIndex == array.Length) + + if (HeaderNames.Connection.Equals(key, StringComparison.OrdinalIgnoreCase)) { + if ((_bits & 0x2L) == 0) + { + _bits |= 0x2L; + _headers._Connection = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("Accept-Encoding", _headers._AcceptEncoding); - ++arrayIndex; - } - if ((_bits & 0x400000L) != 0) - { - if (arrayIndex == array.Length) + if (HeaderNames.UserAgent.Equals(key, StringComparison.OrdinalIgnoreCase)) { + if ((_bits & 0x8000000000L) == 0) + { + _bits |= 0x8000000000L; + _headers._UserAgent = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("Accept-Language", _headers._AcceptLanguage); - ++arrayIndex; - } - if ((_bits & 0x800000L) != 0) - { - if (arrayIndex == array.Length) + if (HeaderNames.KeepAlive.Equals(key, StringComparison.OrdinalIgnoreCase)) { + if ((_bits & 0x8L) == 0) + { + _bits |= 0x8L; + _headers._KeepAlive = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("Authorization", _headers._Authorization); - ++arrayIndex; - } - if ((_bits & 0x1000000L) != 0) - { - if (arrayIndex == array.Length) + if (HeaderNames.RequestId.Equals(key, StringComparison.OrdinalIgnoreCase)) { + if ((_bits & 0x40000000000L) == 0) + { + _bits |= 0x40000000000L; + _headers._RequestId = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("Cookie", _headers._Cookie); - ++arrayIndex; - } - if ((_bits & 0x2000000L) != 0) - { - if (arrayIndex == array.Length) + if (HeaderNames.TraceState.Equals(key, StringComparison.OrdinalIgnoreCase)) { + if ((_bits & 0x200000000000L) == 0) + { + _bits |= 0x200000000000L; + _headers._TraceState = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("Expect", _headers._Expect); - ++arrayIndex; + break; } - if ((_bits & 0x4000000L) != 0) + case 11: { - if (arrayIndex == array.Length) + if (ReferenceEquals(HeaderNames.ContentMD5, key)) { + if ((_bits & 0x8000L) == 0) + { + _bits |= 0x8000L; + _headers._ContentMD5 = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("From", _headers._From); - ++arrayIndex; - } - if ((_bits & 0x8000000L) != 0) - { - if (arrayIndex == array.Length) + if (ReferenceEquals(HeaderNames.TraceParent, key)) { + if ((_bits & 0x100000000000L) == 0) + { + _bits |= 0x100000000000L; + _headers._TraceParent = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("Host", _headers._Host); - ++arrayIndex; - } - if ((_bits & 0x10000000L) != 0) - { - if (arrayIndex == array.Length) + + if (HeaderNames.ContentMD5.Equals(key, StringComparison.OrdinalIgnoreCase)) { + if ((_bits & 0x8000L) == 0) + { + _bits |= 0x8000L; + _headers._ContentMD5 = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("If-Match", _headers._IfMatch); - ++arrayIndex; - } - if ((_bits & 0x20000000L) != 0) - { - if (arrayIndex == array.Length) + if (HeaderNames.TraceParent.Equals(key, StringComparison.OrdinalIgnoreCase)) { + if ((_bits & 0x100000000000L) == 0) + { + _bits |= 0x100000000000L; + _headers._TraceParent = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("If-Modified-Since", _headers._IfModifiedSince); - ++arrayIndex; + break; } - if ((_bits & 0x40000000L) != 0) + case 12: { - if (arrayIndex == array.Length) + if (ReferenceEquals(HeaderNames.ContentType, key)) { + if ((_bits & 0x800L) == 0) + { + _bits |= 0x800L; + _headers._ContentType = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("If-None-Match", _headers._IfNoneMatch); - ++arrayIndex; - } - if ((_bits & 0x80000000L) != 0) - { - if (arrayIndex == array.Length) + if (ReferenceEquals(HeaderNames.MaxForwards, key)) { + if ((_bits & 0x200000000L) == 0) + { + _bits |= 0x200000000L; + _headers._MaxForwards = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("If-Range", _headers._IfRange); - ++arrayIndex; - } - if ((_bits & 0x100000000L) != 0) - { - if (arrayIndex == array.Length) + + if (HeaderNames.ContentType.Equals(key, StringComparison.OrdinalIgnoreCase)) { + if ((_bits & 0x800L) == 0) + { + _bits |= 0x800L; + _headers._ContentType = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("If-Unmodified-Since", _headers._IfUnmodifiedSince); - ++arrayIndex; - } - if ((_bits & 0x200000000L) != 0) - { - if (arrayIndex == array.Length) + if (HeaderNames.MaxForwards.Equals(key, StringComparison.OrdinalIgnoreCase)) { + if ((_bits & 0x200000000L) == 0) + { + _bits |= 0x200000000L; + _headers._MaxForwards = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("Max-Forwards", _headers._MaxForwards); - ++arrayIndex; + break; } - if ((_bits & 0x400000000L) != 0) + case 13: { - if (arrayIndex == array.Length) + if (ReferenceEquals(HeaderNames.CacheControl, key)) { + if ((_bits & 0x1L) == 0) + { + _bits |= 0x1L; + _headers._CacheControl = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("Proxy-Authorization", _headers._ProxyAuthorization); - ++arrayIndex; - } - if ((_bits & 0x800000000L) != 0) - { - if (arrayIndex == array.Length) + if (ReferenceEquals(HeaderNames.ContentRange, key)) { + if ((_bits & 0x10000L) == 0) + { + _bits |= 0x10000L; + _headers._ContentRange = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("Referer", _headers._Referer); - ++arrayIndex; - } - if ((_bits & 0x1000000000L) != 0) - { - if (arrayIndex == array.Length) + if (ReferenceEquals(HeaderNames.LastModified, key)) { + if ((_bits & 0x40000L) == 0) + { + _bits |= 0x40000L; + _headers._LastModified = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("Range", _headers._Range); - ++arrayIndex; - } - if ((_bits & 0x2000000000L) != 0) - { - if (arrayIndex == array.Length) + if (ReferenceEquals(HeaderNames.Authorization, key)) { + if ((_bits & 0x800000L) == 0) + { + _bits |= 0x800000L; + _headers._Authorization = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("TE", _headers._TE); - ++arrayIndex; - } - if ((_bits & 0x4000000000L) != 0) - { - if (arrayIndex == array.Length) + if (ReferenceEquals(HeaderNames.IfNoneMatch, key)) { + if ((_bits & 0x40000000L) == 0) + { + _bits |= 0x40000000L; + _headers._IfNoneMatch = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("Translate", _headers._Translate); - ++arrayIndex; - } - if ((_bits & 0x8000000000L) != 0) - { - if (arrayIndex == array.Length) + + if (HeaderNames.CacheControl.Equals(key, StringComparison.OrdinalIgnoreCase)) { + if ((_bits & 0x1L) == 0) + { + _bits |= 0x1L; + _headers._CacheControl = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("User-Agent", _headers._UserAgent); - ++arrayIndex; - } - if ((_bits & 0x10000000000L) != 0) - { - if (arrayIndex == array.Length) + if (HeaderNames.ContentRange.Equals(key, StringComparison.OrdinalIgnoreCase)) { + if ((_bits & 0x10000L) == 0) + { + _bits |= 0x10000L; + _headers._ContentRange = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("DNT", _headers._DNT); - ++arrayIndex; - } - if ((_bits & 0x20000000000L) != 0) - { - if (arrayIndex == array.Length) + if (HeaderNames.LastModified.Equals(key, StringComparison.OrdinalIgnoreCase)) { + if ((_bits & 0x40000L) == 0) + { + _bits |= 0x40000L; + _headers._LastModified = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("Upgrade-Insecure-Requests", _headers._UpgradeInsecureRequests); - ++arrayIndex; - } - if ((_bits & 0x40000000000L) != 0) - { - if (arrayIndex == array.Length) + if (HeaderNames.Authorization.Equals(key, StringComparison.OrdinalIgnoreCase)) { + if ((_bits & 0x800000L) == 0) + { + _bits |= 0x800000L; + _headers._Authorization = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("Origin", _headers._Origin); - ++arrayIndex; - } - if ((_bits & 0x80000000000L) != 0) - { - if (arrayIndex == array.Length) + if (HeaderNames.IfNoneMatch.Equals(key, StringComparison.OrdinalIgnoreCase)) { + if ((_bits & 0x40000000L) == 0) + { + _bits |= 0x40000000L; + _headers._IfNoneMatch = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("Access-Control-Request-Method", _headers._AccessControlRequestMethod); - ++arrayIndex; + break; } - if ((_bits & 0x100000000000L) != 0) + case 14: { - if (arrayIndex == array.Length) + if (ReferenceEquals(HeaderNames.AcceptCharset, key)) { + if ((_bits & 0x100000L) == 0) + { + _bits |= 0x100000L; + _headers._AcceptCharset = value; + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("Access-Control-Request-Headers", _headers._AccessControlRequestHeaders); - ++arrayIndex; - } - if (_contentLength.HasValue) - { - if (arrayIndex == array.Length) + if (ReferenceEquals(HeaderNames.ContentLength, key)) { + if (!_contentLength.HasValue) + { + _contentLength = ParseContentLength(value); + return true; + } return false; } - array[arrayIndex] = new KeyValuePair("Content-Length", HeaderUtilities.FormatNonNegativeInt64(_contentLength.Value)); - ++arrayIndex; - } - ((ICollection>)MaybeUnknown)?.CopyTo(array, arrayIndex); - - return true; - } - - [MethodImpl(MethodImplOptions.AggressiveOptimization)] - public unsafe void Append(Span name, Span value) - { - ref byte nameStart = ref MemoryMarshal.GetReference(name); - ref StringValues values = ref Unsafe.AsRef(null); - var flag = 0L; - - // Does the name matched any "known" headers - switch (name.Length) - { - case 2: - if (((Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfu) == 0x4554u)) + + if (HeaderNames.AcceptCharset.Equals(key, StringComparison.OrdinalIgnoreCase)) { - flag = 0x2000000000L; - values = ref _headers._TE; + if ((_bits & 0x100000L) == 0) + { + _bits |= 0x100000L; + _headers._AcceptCharset = value; + return true; + } + return false; } - break; - case 3: - var firstTerm3 = (Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfu); - if ((firstTerm3 == 0x4e44u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)2) & 0xdfu) == 0x54u)) + if (HeaderNames.ContentLength.Equals(key, StringComparison.OrdinalIgnoreCase)) { - flag = 0x10000000000L; - values = ref _headers._DNT; + if (!_contentLength.HasValue) + { + _contentLength = ParseContentLength(value); + return true; + } + return false; } - else if ((firstTerm3 == 0x4956u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)2) & 0xdfu) == 0x41u)) + break; + } + case 15: + { + if (ReferenceEquals(HeaderNames.AcceptEncoding, key)) { - flag = 0x100L; - values = ref _headers._Via; + if ((_bits & 0x200000L) == 0) + { + _bits |= 0x200000L; + _headers._AcceptEncoding = value; + return true; + } + return false; } - break; - case 4: - var firstTerm4 = (Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfdfdfu); - if ((firstTerm4 == 0x54534f48u)) + if (ReferenceEquals(HeaderNames.AcceptLanguage, key)) { - flag = 0x8000000L; - values = ref _headers._Host; + if ((_bits & 0x400000L) == 0) + { + _bits |= 0x400000L; + _headers._AcceptLanguage = value; + return true; + } + return false; } - else if ((firstTerm4 == 0x45544144u)) + + if (HeaderNames.AcceptEncoding.Equals(key, StringComparison.OrdinalIgnoreCase)) { - flag = 0x4L; - values = ref _headers._Date; + if ((_bits & 0x200000L) == 0) + { + _bits |= 0x200000L; + _headers._AcceptEncoding = value; + return true; + } + return false; } - else if ((firstTerm4 == 0x4d4f5246u)) + if (HeaderNames.AcceptLanguage.Equals(key, StringComparison.OrdinalIgnoreCase)) { - flag = 0x4000000L; - values = ref _headers._From; + if ((_bits & 0x400000L) == 0) + { + _bits |= 0x400000L; + _headers._AcceptLanguage = value; + return true; + } + return false; } break; - case 5: - var firstTerm5 = (Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfdfdfu); - if ((firstTerm5 == 0x4f4c4c41u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)4) & 0xdfu) == 0x57u)) + } + case 16: + { + if (ReferenceEquals(HeaderNames.ContentEncoding, key)) { - flag = 0x400L; - values = ref _headers._Allow; + if ((_bits & 0x1000L) == 0) + { + _bits |= 0x1000L; + _headers._ContentEncoding = value; + return true; + } + return false; } - else if ((firstTerm5 == 0x474e4152u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)4) & 0xdfu) == 0x45u)) + if (ReferenceEquals(HeaderNames.ContentLanguage, key)) { - flag = 0x1000000000L; - values = ref _headers._Range; + if ((_bits & 0x2000L) == 0) + { + _bits |= 0x2000L; + _headers._ContentLanguage = value; + return true; + } + return false; } - break; - case 6: - var firstTerm6 = (Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfdfdfu); - if ((firstTerm6 == 0x45434341u) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(ushort)))) & 0xdfdfu) == 0x5450u)) + if (ReferenceEquals(HeaderNames.ContentLocation, key)) { - flag = 0x80000L; - values = ref _headers._Accept; + if ((_bits & 0x4000L) == 0) + { + _bits |= 0x4000L; + _headers._ContentLocation = value; + return true; + } + return false; } - else if ((firstTerm6 == 0x4b4f4f43u) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(ushort)))) & 0xdfdfu) == 0x4549u)) + + if (HeaderNames.ContentEncoding.Equals(key, StringComparison.OrdinalIgnoreCase)) { - flag = 0x1000000L; - values = ref _headers._Cookie; + if ((_bits & 0x1000L) == 0) + { + _bits |= 0x1000L; + _headers._ContentEncoding = value; + return true; + } + return false; } - else if ((firstTerm6 == 0x45505845u) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(ushort)))) & 0xdfdfu) == 0x5443u)) + if (HeaderNames.ContentLanguage.Equals(key, StringComparison.OrdinalIgnoreCase)) { - flag = 0x2000000L; - values = ref _headers._Expect; + if ((_bits & 0x2000L) == 0) + { + _bits |= 0x2000L; + _headers._ContentLanguage = value; + return true; + } + return false; } - else if ((firstTerm6 == 0x4749524fu) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(ushort)))) & 0xdfdfu) == 0x4e49u)) + if (HeaderNames.ContentLocation.Equals(key, StringComparison.OrdinalIgnoreCase)) { - flag = 0x40000000000L; - values = ref _headers._Origin; + if ((_bits & 0x4000L) == 0) + { + _bits |= 0x4000L; + _headers._ContentLocation = value; + return true; + } + return false; } - else if ((firstTerm6 == 0x47415250u) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(ushort)))) & 0xdfdfu) == 0x414du)) + break; + } + case 17: + { + if (ReferenceEquals(HeaderNames.TransferEncoding, key)) { - flag = 0x10L; - values = ref _headers._Pragma; + if ((_bits & 0x40L) == 0) + { + _bits |= 0x40L; + _headers._TransferEncoding = value; + return true; + } + return false; } - break; - case 7: - var firstTerm7 = (Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfdfdfu); - if ((firstTerm7 == 0x49505845u) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(ushort)))) & 0xdfdfu) == 0x4552u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)6) & 0xdfu) == 0x53u)) + if (ReferenceEquals(HeaderNames.IfModifiedSince, key)) { - flag = 0x20000L; - values = ref _headers._Expires; + if ((_bits & 0x20000000L) == 0) + { + _bits |= 0x20000000L; + _headers._IfModifiedSince = value; + return true; + } + return false; } - else if ((firstTerm7 == 0x45464552u) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(ushort)))) & 0xdfdfu) == 0x4552u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)6) & 0xdfu) == 0x52u)) + + if (HeaderNames.TransferEncoding.Equals(key, StringComparison.OrdinalIgnoreCase)) { - flag = 0x800000000L; - values = ref _headers._Referer; + if ((_bits & 0x40L) == 0) + { + _bits |= 0x40L; + _headers._TransferEncoding = value; + return true; + } + return false; } - else if ((firstTerm7 == 0x49415254u) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(ushort)))) & 0xdfdfu) == 0x454cu) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)6) & 0xdfu) == 0x52u)) + if (HeaderNames.IfModifiedSince.Equals(key, StringComparison.OrdinalIgnoreCase)) { - flag = 0x20L; - values = ref _headers._Trailer; + if ((_bits & 0x20000000L) == 0) + { + _bits |= 0x20000000L; + _headers._IfModifiedSince = value; + return true; + } + return false; } - else if ((firstTerm7 == 0x52475055u) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(ushort)))) & 0xdfdfu) == 0x4441u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)6) & 0xdfu) == 0x45u)) + break; + } + case 19: + { + if (ReferenceEquals(HeaderNames.IfUnmodifiedSince, key)) { - flag = 0x80L; - values = ref _headers._Upgrade; + if ((_bits & 0x100000000L) == 0) + { + _bits |= 0x100000000L; + _headers._IfUnmodifiedSince = value; + return true; + } + return false; } - else if ((firstTerm7 == 0x4e524157u) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(ushort)))) & 0xdfdfu) == 0x4e49u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)6) & 0xdfu) == 0x47u)) + if (ReferenceEquals(HeaderNames.ProxyAuthorization, key)) { - flag = 0x200L; - values = ref _headers._Warning; + if ((_bits & 0x400000000L) == 0) + { + _bits |= 0x400000000L; + _headers._ProxyAuthorization = value; + return true; + } + return false; } - break; - case 8: - var firstTerm8 = (Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfdfdfdfffdfdfuL); - if ((firstTerm8 == 0x484354414d2d4649uL)) + if (ReferenceEquals(HeaderNames.CorrelationContext, key)) { - flag = 0x10000000L; - values = ref _headers._IfMatch; + if ((_bits & 0x80000000000L) == 0) + { + _bits |= 0x80000000000L; + _headers._CorrelationContext = value; + return true; + } + return false; } - else if ((firstTerm8 == 0x45474e41522d4649uL)) + + if (HeaderNames.IfUnmodifiedSince.Equals(key, StringComparison.OrdinalIgnoreCase)) { - flag = 0x80000000L; - values = ref _headers._IfRange; + if ((_bits & 0x100000000L) == 0) + { + _bits |= 0x100000000L; + _headers._IfUnmodifiedSince = value; + return true; + } + return false; } - break; - case 9: - if (((Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfdfdfdfdfdfdfuL) == 0x54414c534e415254uL) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)8) & 0xdfu) == 0x45u)) + if (HeaderNames.ProxyAuthorization.Equals(key, StringComparison.OrdinalIgnoreCase)) { - flag = 0x4000000000L; - values = ref _headers._Translate; + if ((_bits & 0x400000000L) == 0) + { + _bits |= 0x400000000L; + _headers._ProxyAuthorization = value; + return true; + } + return false; } - break; - case 10: - if (((Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfdfdfdfdfdfdfuL) == 0x495443454e4e4f43uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(4 * sizeof(ushort)))) & 0xdfdfu) == 0x4e4fu)) + if (HeaderNames.CorrelationContext.Equals(key, StringComparison.OrdinalIgnoreCase)) { - flag = 0x2L; - values = ref _headers._Connection; + if ((_bits & 0x80000000000L) == 0) + { + _bits |= 0x80000000000L; + _headers._CorrelationContext = value; + return true; + } + return false; } - else if (((Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfdfffdfdfdfdfuL) == 0x4547412d52455355uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(4 * sizeof(ushort)))) & 0xdfdfu) == 0x544eu)) + break; + } + case 25: + { + if (ReferenceEquals(HeaderNames.UpgradeInsecureRequests, key)) { - flag = 0x8000000000L; - values = ref _headers._UserAgent; + if ((_bits & 0x20000000000L) == 0) + { + _bits |= 0x20000000000L; + _headers._UpgradeInsecureRequests = value; + return true; + } + return false; } - else if (((Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfdfffdfdfdfdfuL) == 0x494c412d5045454buL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(4 * sizeof(ushort)))) & 0xdfdfu) == 0x4556u)) + + if (HeaderNames.UpgradeInsecureRequests.Equals(key, StringComparison.OrdinalIgnoreCase)) { - flag = 0x8L; - values = ref _headers._KeepAlive; + if ((_bits & 0x20000000000L) == 0) + { + _bits |= 0x20000000000L; + _headers._UpgradeInsecureRequests = value; + return true; + } + return false; } break; - case 11: - if (((Unsafe.ReadUnaligned(ref nameStart) & 0xffdfdfdfdfdfdfdfuL) == 0x2d544e45544e4f43uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(4 * sizeof(ushort)))) & 0xdfdfu) == 0x444du) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)10) & 0xffu) == 0x35u)) + } + case 29: + { + if (ReferenceEquals(HeaderNames.AccessControlRequestMethod, key)) { - flag = 0x8000L; - values = ref _headers._ContentMD5; + if ((_bits & 0x800000000000L) == 0) + { + _bits |= 0x800000000000L; + _headers._AccessControlRequestMethod = value; + return true; + } + return false; + } + + if (HeaderNames.AccessControlRequestMethod.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x800000000000L) == 0) + { + _bits |= 0x800000000000L; + _headers._AccessControlRequestMethod = value; + return true; + } + return false; } break; - case 12: - if (((Unsafe.ReadUnaligned(ref nameStart) & 0xffdfdfdfdfdfdfdfuL) == 0x2d544e45544e4f43uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(uint)))) & 0xdfdfdfdfu) == 0x45505954u)) + } + case 30: + { + if (ReferenceEquals(HeaderNames.AccessControlRequestHeaders, key)) { - flag = 0x800L; - values = ref _headers._ContentType; + if ((_bits & 0x1000000000000L) == 0) + { + _bits |= 0x1000000000000L; + _headers._AccessControlRequestHeaders = value; + return true; + } + return false; } - else if (((Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfdfdfffdfdfdfuL) == 0x57524f462d58414duL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(uint)))) & 0xdfdfdfdfu) == 0x53445241u)) + + if (HeaderNames.AccessControlRequestHeaders.Equals(key, StringComparison.OrdinalIgnoreCase)) { - flag = 0x200000000L; - values = ref _headers._MaxForwards; + if ((_bits & 0x1000000000000L) == 0) + { + _bits |= 0x1000000000000L; + _headers._AccessControlRequestHeaders = value; + return true; + } + return false; } break; - case 13: - if (((Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfdfdfdfdfdfdfuL) == 0x5a49524f48545541uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(uint)))) & 0xdfdfdfdfu) == 0x4f495441u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)12) & 0xdfu) == 0x4eu)) + } + } + + return AddValueUnknown(key, value); + } + + protected override bool RemoveFast(string key) + { + switch (key.Length) + { + case 2: + { + if (ReferenceEquals(HeaderNames.TE, key)) { - flag = 0x800000L; - values = ref _headers._Authorization; + if ((_bits & 0x2000000000L) != 0) + { + _bits &= ~0x2000000000L; + _headers._TE = default(StringValues); + return true; + } + return false; } - else if (((Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfffdfdfdfdfdfuL) == 0x4f432d4548434143uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(uint)))) & 0xdfdfdfdfu) == 0x4f52544eu) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)12) & 0xdfu) == 0x4cu)) + + if (HeaderNames.TE.Equals(key, StringComparison.OrdinalIgnoreCase)) { - flag = 0x1L; - values = ref _headers._CacheControl; + if ((_bits & 0x2000000000L) != 0) + { + _bits &= ~0x2000000000L; + _headers._TE = default(StringValues); + return true; + } + return false; } - else if (((Unsafe.ReadUnaligned(ref nameStart) & 0xffdfdfdfdfdfdfdfuL) == 0x2d544e45544e4f43uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(uint)))) & 0xdfdfdfdfu) == 0x474e4152u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)12) & 0xdfu) == 0x45u)) + break; + } + case 3: + { + if (ReferenceEquals(HeaderNames.Via, key)) { - flag = 0x10000L; - values = ref _headers._ContentRange; + if ((_bits & 0x100L) != 0) + { + _bits &= ~0x100L; + _headers._Via = default(StringValues); + return true; + } + return false; } - else if (((Unsafe.ReadUnaligned(ref nameStart) & 0xffdfdfdfdfffdfdfuL) == 0x2d454e4f4e2d4649uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(uint)))) & 0xdfdfdfdfu) == 0x4354414du) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)12) & 0xdfu) == 0x48u)) + if (ReferenceEquals(HeaderNames.DNT, key)) { - flag = 0x40000000L; - values = ref _headers._IfNoneMatch; + if ((_bits & 0x10000000000L) != 0) + { + _bits &= ~0x10000000000L; + _headers._DNT = default(StringValues); + return true; + } + return false; } - else if (((Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfdfffdfdfdfdfuL) == 0x444f4d2d5453414cuL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(uint)))) & 0xdfdfdfdfu) == 0x45494649u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)12) & 0xdfu) == 0x44u)) + + if (HeaderNames.Via.Equals(key, StringComparison.OrdinalIgnoreCase)) { - flag = 0x40000L; - values = ref _headers._LastModified; + if ((_bits & 0x100L) != 0) + { + _bits &= ~0x100L; + _headers._Via = default(StringValues); + return true; + } + return false; } - break; - case 14: - if (((Unsafe.ReadUnaligned(ref nameStart) & 0xdfffdfdfdfdfdfdfuL) == 0x432d545045434341uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(uint)))) & 0xdfdfdfdfu) == 0x53524148u) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(6 * sizeof(ushort)))) & 0xdfdfu) == 0x5445u)) + if (HeaderNames.DNT.Equals(key, StringComparison.OrdinalIgnoreCase)) { - flag = 0x100000L; - values = ref _headers._AcceptCharset; + if ((_bits & 0x10000000000L) != 0) + { + _bits &= ~0x10000000000L; + _headers._DNT = default(StringValues); + return true; + } + return false; } - else if (((Unsafe.ReadUnaligned(ref nameStart) & 0xffdfdfdfdfdfdfdfuL) == 0x2d544e45544e4f43uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(uint)))) & 0xdfdfdfdfu) == 0x474e454cu) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(6 * sizeof(ushort)))) & 0xdfdfu) == 0x4854u)) + break; + } + case 4: + { + if (ReferenceEquals(HeaderNames.Host, key)) { - AppendContentLength(value); - return; + if ((_bits & 0x8000000L) != 0) + { + _bits &= ~0x8000000L; + _headers._Host = default(StringValues); + return true; + } + return false; } - break; - case 15: - var firstTerm15 = (Unsafe.ReadUnaligned(ref nameStart) & 0xdfffdfdfdfdfdfdfuL); - if ((firstTerm15 == 0x452d545045434341uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(uint)))) & 0xdfdfdfdfu) == 0x444f434eu) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(6 * sizeof(ushort)))) & 0xdfdfu) == 0x4e49u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)14) & 0xdfu) == 0x47u)) + if (ReferenceEquals(HeaderNames.Date, key)) { - flag = 0x200000L; - values = ref _headers._AcceptEncoding; + if ((_bits & 0x4L) != 0) + { + _bits &= ~0x4L; + _headers._Date = default(StringValues); + return true; + } + return false; } - else if ((firstTerm15 == 0x4c2d545045434341uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(uint)))) & 0xdfdfdfdfu) == 0x55474e41u) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(6 * sizeof(ushort)))) & 0xdfdfu) == 0x4741u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)14) & 0xdfu) == 0x45u)) + if (ReferenceEquals(HeaderNames.From, key)) { - flag = 0x400000L; - values = ref _headers._AcceptLanguage; + if ((_bits & 0x4000000L) != 0) + { + _bits &= ~0x4000000L; + _headers._From = default(StringValues); + return true; + } + return false; } - break; - case 16: - var firstTerm16 = (Unsafe.ReadUnaligned(ref nameStart) & 0xffdfdfdfdfdfdfdfuL); - if ((firstTerm16 == 0x2d544e45544e4f43uL)) + + if (HeaderNames.Host.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)sizeof(ulong))) & 0xdfdfdfdfdfdfdfdfuL) == 0x474e49444f434e45uL)) + if ((_bits & 0x8000000L) != 0) { - flag = 0x1000L; - values = ref _headers._ContentEncoding; + _bits &= ~0x8000000L; + _headers._Host = default(StringValues); + return true; } - else if (((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)sizeof(ulong))) & 0xdfdfdfdfdfdfdfdfuL) == 0x45474155474e414cuL)) + return false; + } + if (HeaderNames.Date.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x4L) != 0) { - flag = 0x2000L; - values = ref _headers._ContentLanguage; + _bits &= ~0x4L; + _headers._Date = default(StringValues); + return true; } - else if (((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)sizeof(ulong))) & 0xdfdfdfdfdfdfdfdfuL) == 0x4e4f495441434f4cuL)) + return false; + } + if (HeaderNames.From.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x4000000L) != 0) { - flag = 0x4000L; - values = ref _headers._ContentLocation; + _bits &= ~0x4000000L; + _headers._From = default(StringValues); + return true; } + return false; } break; - case 17: - if (((Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfdfdfdfffdfdfuL) == 0x4649444f4d2d4649uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)sizeof(ulong))) & 0xdfdfdfdfffdfdfdfuL) == 0x434e49532d444549uL) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)16) & 0xdfu) == 0x45u)) + } + case 5: + { + if (ReferenceEquals(HeaderNames.Allow, key)) { - flag = 0x20000000L; - values = ref _headers._IfModifiedSince; + if ((_bits & 0x400L) != 0) + { + _bits &= ~0x400L; + _headers._Allow = default(StringValues); + return true; + } + return false; } - else if (((Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfdfdfdfdfdfdfuL) == 0x524546534e415254uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)sizeof(ulong))) & 0xdfdfdfdfdfdfdfffuL) == 0x4e49444f434e452duL) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)16) & 0xdfu) == 0x47u)) + if (ReferenceEquals(HeaderNames.Range, key)) { - flag = 0x40L; - values = ref _headers._TransferEncoding; + if ((_bits & 0x1000000000L) != 0) + { + _bits &= ~0x1000000000L; + _headers._Range = default(StringValues); + return true; + } + return false; } - break; - case 19: - if (((Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfdfdfdfffdfdfuL) == 0x444f4d4e552d4649uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)sizeof(ulong))) & 0xdfdfffdfdfdfdfdfuL) == 0x49532d4445494649uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(8 * sizeof(ushort)))) & 0xdfdfu) == 0x434eu) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)18) & 0xdfu) == 0x45u)) + + if (HeaderNames.Allow.Equals(key, StringComparison.OrdinalIgnoreCase)) { - flag = 0x100000000L; - values = ref _headers._IfUnmodifiedSince; + if ((_bits & 0x400L) != 0) + { + _bits &= ~0x400L; + _headers._Allow = default(StringValues); + return true; + } + return false; } - else if (((Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfffdfdfdfdfdfuL) == 0x55412d59584f5250uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)sizeof(ulong))) & 0xdfdfdfdfdfdfdfdfuL) == 0x54415a49524f4854uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(8 * sizeof(ushort)))) & 0xdfdfu) == 0x4f49u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)18) & 0xdfu) == 0x4eu)) + if (HeaderNames.Range.Equals(key, StringComparison.OrdinalIgnoreCase)) { - flag = 0x400000000L; - values = ref _headers._ProxyAuthorization; + if ((_bits & 0x1000000000L) != 0) + { + _bits &= ~0x1000000000L; + _headers._Range = default(StringValues); + return true; + } + return false; } break; - case 25: - if (((Unsafe.ReadUnaligned(ref nameStart) & 0xffdfdfdfdfdfdfdfuL) == 0x2d45444152475055uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)sizeof(ulong))) & 0xdfdfdfdfdfdfdfdfuL) == 0x4552554345534e49uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(ulong)))) & 0xdfdfdfdfdfdfdfffuL) == 0x545345555145522duL) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)24) & 0xdfu) == 0x53u)) + } + case 6: + { + if (ReferenceEquals(HeaderNames.Accept, key)) { - flag = 0x20000000000L; - values = ref _headers._UpgradeInsecureRequests; + if ((_bits & 0x80000L) != 0) + { + _bits &= ~0x80000L; + _headers._Accept = default(StringValues); + return true; + } + return false; } - break; - case 29: - if (((Unsafe.ReadUnaligned(ref nameStart) & 0xdfffdfdfdfdfdfdfuL) == 0x432d535345434341uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)sizeof(ulong))) & 0xdfffdfdfdfdfdfdfuL) == 0x522d4c4f52544e4fuL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(ulong)))) & 0xdfffdfdfdfdfdfdfuL) == 0x4d2d545345555145uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(6 * sizeof(uint)))) & 0xdfdfdfdfu) == 0x4f485445u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)28) & 0xdfu) == 0x44u)) + if (ReferenceEquals(HeaderNames.Pragma, key)) { - flag = 0x80000000000L; - values = ref _headers._AccessControlRequestMethod; + if ((_bits & 0x10L) != 0) + { + _bits &= ~0x10L; + _headers._Pragma = default(StringValues); + return true; + } + return false; } - break; - case 30: - if (((Unsafe.ReadUnaligned(ref nameStart) & 0xdfffdfdfdfdfdfdfuL) == 0x432d535345434341uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)sizeof(ulong))) & 0xdfffdfdfdfdfdfdfuL) == 0x522d4c4f52544e4fuL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(ulong)))) & 0xdfffdfdfdfdfdfdfuL) == 0x482d545345555145uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(6 * sizeof(uint)))) & 0xdfdfdfdfu) == 0x45444145u) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(14 * sizeof(ushort)))) & 0xdfdfu) == 0x5352u)) + if (ReferenceEquals(HeaderNames.Cookie, key)) { - flag = 0x100000000000L; - values = ref _headers._AccessControlRequestHeaders; + if ((_bits & 0x1000000L) != 0) + { + _bits &= ~0x1000000L; + _headers._Cookie = default(StringValues); + return true; + } + return false; } - break; - } - - if (flag != 0) - { - // Matched a known header - if ((_previousBits & flag) != 0) - { - // Had a previous string for this header, mark it as used so we don't clear it OnHeadersComplete or consider it if we get a second header - _previousBits ^= flag; - - // We will only reuse this header if there was only one previous header - if (values.Count == 1) + if (ReferenceEquals(HeaderNames.Expect, key)) { - var previousValue = values.ToString(); - // Check lengths are the same, then if the bytes were converted to an ascii string if they would be the same. - // We do not consider Utf8 headers for reuse. - if (previousValue.Length == value.Length && - StringUtilities.BytesOrdinalEqualsStringAndAscii(previousValue, value)) + if ((_bits & 0x2000000L) != 0) { - // The previous string matches what the bytes would convert to, so we will just use that one. - _bits |= flag; - return; + _bits &= ~0x2000000L; + _headers._Expect = default(StringValues); + return true; } + return false; } - } - - // We didn't have a previous matching header value, or have already added a header, so get the string for this value. - var valueStr = value.GetAsciiOrUTF8StringNonNullCharacters(); - if ((_bits & flag) == 0) - { - // We didn't already have a header set, so add a new one. - _bits |= flag; - values = new StringValues(valueStr); - } - else - { - // We already had a header set, so concatenate the new one. - values = AppendValue(values, valueStr); - } - } - else - { - // The header was not one of the "known" headers. - // Convert value to string first, because passing two spans causes 8 bytes stack zeroing in - // this method with rep stosd, which is slower than necessary. - var valueStr = value.GetAsciiOrUTF8StringNonNullCharacters(); - AppendUnknownHeaders(name, valueStr); - } - } - - private struct HeaderReferences - { - public StringValues _CacheControl; - public StringValues _Connection; - public StringValues _Date; - public StringValues _KeepAlive; - public StringValues _Pragma; - public StringValues _Trailer; - public StringValues _TransferEncoding; - public StringValues _Upgrade; - public StringValues _Via; - public StringValues _Warning; - public StringValues _Allow; - public StringValues _ContentType; - public StringValues _ContentEncoding; - public StringValues _ContentLanguage; - public StringValues _ContentLocation; - public StringValues _ContentMD5; - public StringValues _ContentRange; - public StringValues _Expires; - public StringValues _LastModified; - public StringValues _Accept; - public StringValues _AcceptCharset; - public StringValues _AcceptEncoding; - public StringValues _AcceptLanguage; - public StringValues _Authorization; - public StringValues _Cookie; - public StringValues _Expect; - public StringValues _From; - public StringValues _Host; - public StringValues _IfMatch; - public StringValues _IfModifiedSince; - public StringValues _IfNoneMatch; - public StringValues _IfRange; - public StringValues _IfUnmodifiedSince; - public StringValues _MaxForwards; - public StringValues _ProxyAuthorization; - public StringValues _Referer; - public StringValues _Range; - public StringValues _TE; - public StringValues _Translate; - public StringValues _UserAgent; - public StringValues _DNT; - public StringValues _UpgradeInsecureRequests; - public StringValues _Origin; - public StringValues _AccessControlRequestMethod; - public StringValues _AccessControlRequestHeaders; - - } - - public partial struct Enumerator - { - // Compiled to Jump table - public bool MoveNext() - { - switch (_next) - { - case 0: - goto HeaderCacheControl; - case 1: - goto HeaderConnection; - case 2: - goto HeaderDate; - case 3: - goto HeaderKeepAlive; - case 4: - goto HeaderPragma; - case 5: - goto HeaderTrailer; - case 6: - goto HeaderTransferEncoding; - case 7: - goto HeaderUpgrade; - case 8: - goto HeaderVia; - case 9: - goto HeaderWarning; - case 10: - goto HeaderAllow; - case 11: - goto HeaderContentType; - case 12: - goto HeaderContentEncoding; - case 13: - goto HeaderContentLanguage; - case 14: - goto HeaderContentLocation; - case 15: - goto HeaderContentMD5; - case 16: - goto HeaderContentRange; - case 17: - goto HeaderExpires; - case 18: - goto HeaderLastModified; - case 19: - goto HeaderAccept; - case 20: - goto HeaderAcceptCharset; - case 21: - goto HeaderAcceptEncoding; - case 22: - goto HeaderAcceptLanguage; - case 23: - goto HeaderAuthorization; - case 24: - goto HeaderCookie; - case 25: - goto HeaderExpect; - case 26: - goto HeaderFrom; - case 27: - goto HeaderHost; - case 28: - goto HeaderIfMatch; - case 29: - goto HeaderIfModifiedSince; - case 30: - goto HeaderIfNoneMatch; - case 31: - goto HeaderIfRange; - case 32: - goto HeaderIfUnmodifiedSince; - case 33: - goto HeaderMaxForwards; - case 34: - goto HeaderProxyAuthorization; - case 35: - goto HeaderReferer; - case 36: - goto HeaderRange; - case 37: - goto HeaderTE; - case 38: - goto HeaderTranslate; - case 39: - goto HeaderUserAgent; - case 40: - goto HeaderDNT; - case 41: - goto HeaderUpgradeInsecureRequests; - case 42: - goto HeaderOrigin; - case 43: - goto HeaderAccessControlRequestMethod; - case 44: - goto HeaderAccessControlRequestHeaders; - case 45: - goto HeaderContentLength; - default: - goto ExtraHeaders; - } - - HeaderCacheControl: // case 0 - if ((_bits & 0x1L) != 0) + if (ReferenceEquals(HeaderNames.Origin, key)) { - _current = new KeyValuePair("Cache-Control", _collection._headers._CacheControl); - _next = 1; - return true; + if ((_bits & 0x400000000000L) != 0) + { + _bits &= ~0x400000000000L; + _headers._Origin = default(StringValues); + return true; + } + return false; } - HeaderConnection: // case 1 - if ((_bits & 0x2L) != 0) + + if (HeaderNames.Accept.Equals(key, StringComparison.OrdinalIgnoreCase)) { - _current = new KeyValuePair("Connection", _collection._headers._Connection); - _next = 2; - return true; + if ((_bits & 0x80000L) != 0) + { + _bits &= ~0x80000L; + _headers._Accept = default(StringValues); + return true; + } + return false; } - HeaderDate: // case 2 - if ((_bits & 0x4L) != 0) + if (HeaderNames.Pragma.Equals(key, StringComparison.OrdinalIgnoreCase)) { - _current = new KeyValuePair("Date", _collection._headers._Date); - _next = 3; - return true; + if ((_bits & 0x10L) != 0) + { + _bits &= ~0x10L; + _headers._Pragma = default(StringValues); + return true; + } + return false; } - HeaderKeepAlive: // case 3 - if ((_bits & 0x8L) != 0) + if (HeaderNames.Cookie.Equals(key, StringComparison.OrdinalIgnoreCase)) { - _current = new KeyValuePair("Keep-Alive", _collection._headers._KeepAlive); - _next = 4; - return true; + if ((_bits & 0x1000000L) != 0) + { + _bits &= ~0x1000000L; + _headers._Cookie = default(StringValues); + return true; + } + return false; } - HeaderPragma: // case 4 - if ((_bits & 0x10L) != 0) + if (HeaderNames.Expect.Equals(key, StringComparison.OrdinalIgnoreCase)) { - _current = new KeyValuePair("Pragma", _collection._headers._Pragma); - _next = 5; - return true; + if ((_bits & 0x2000000L) != 0) + { + _bits &= ~0x2000000L; + _headers._Expect = default(StringValues); + return true; + } + return false; } - HeaderTrailer: // case 5 - if ((_bits & 0x20L) != 0) + if (HeaderNames.Origin.Equals(key, StringComparison.OrdinalIgnoreCase)) { - _current = new KeyValuePair("Trailer", _collection._headers._Trailer); - _next = 6; - return true; + if ((_bits & 0x400000000000L) != 0) + { + _bits &= ~0x400000000000L; + _headers._Origin = default(StringValues); + return true; + } + return false; } - HeaderTransferEncoding: // case 6 - if ((_bits & 0x40L) != 0) + break; + } + case 7: + { + if (ReferenceEquals(HeaderNames.Trailer, key)) { - _current = new KeyValuePair("Transfer-Encoding", _collection._headers._TransferEncoding); - _next = 7; - return true; + if ((_bits & 0x20L) != 0) + { + _bits &= ~0x20L; + _headers._Trailer = default(StringValues); + return true; + } + return false; } - HeaderUpgrade: // case 7 - if ((_bits & 0x80L) != 0) + if (ReferenceEquals(HeaderNames.Upgrade, key)) { - _current = new KeyValuePair("Upgrade", _collection._headers._Upgrade); - _next = 8; - return true; - } - HeaderVia: // case 8 - if ((_bits & 0x100L) != 0) - { - _current = new KeyValuePair("Via", _collection._headers._Via); - _next = 9; - return true; + if ((_bits & 0x80L) != 0) + { + _bits &= ~0x80L; + _headers._Upgrade = default(StringValues); + return true; + } + return false; } - HeaderWarning: // case 9 - if ((_bits & 0x200L) != 0) + if (ReferenceEquals(HeaderNames.Warning, key)) { - _current = new KeyValuePair("Warning", _collection._headers._Warning); - _next = 10; - return true; + if ((_bits & 0x200L) != 0) + { + _bits &= ~0x200L; + _headers._Warning = default(StringValues); + return true; + } + return false; } - HeaderAllow: // case 10 - if ((_bits & 0x400L) != 0) + if (ReferenceEquals(HeaderNames.Expires, key)) { - _current = new KeyValuePair("Allow", _collection._headers._Allow); - _next = 11; - return true; + if ((_bits & 0x20000L) != 0) + { + _bits &= ~0x20000L; + _headers._Expires = default(StringValues); + return true; + } + return false; } - HeaderContentType: // case 11 - if ((_bits & 0x800L) != 0) + if (ReferenceEquals(HeaderNames.Referer, key)) { - _current = new KeyValuePair("Content-Type", _collection._headers._ContentType); - _next = 12; - return true; + if ((_bits & 0x800000000L) != 0) + { + _bits &= ~0x800000000L; + _headers._Referer = default(StringValues); + return true; + } + return false; } - HeaderContentEncoding: // case 12 - if ((_bits & 0x1000L) != 0) + + if (HeaderNames.Trailer.Equals(key, StringComparison.OrdinalIgnoreCase)) { - _current = new KeyValuePair("Content-Encoding", _collection._headers._ContentEncoding); - _next = 13; - return true; + if ((_bits & 0x20L) != 0) + { + _bits &= ~0x20L; + _headers._Trailer = default(StringValues); + return true; + } + return false; } - HeaderContentLanguage: // case 13 - if ((_bits & 0x2000L) != 0) + if (HeaderNames.Upgrade.Equals(key, StringComparison.OrdinalIgnoreCase)) { - _current = new KeyValuePair("Content-Language", _collection._headers._ContentLanguage); - _next = 14; - return true; + if ((_bits & 0x80L) != 0) + { + _bits &= ~0x80L; + _headers._Upgrade = default(StringValues); + return true; + } + return false; } - HeaderContentLocation: // case 14 - if ((_bits & 0x4000L) != 0) + if (HeaderNames.Warning.Equals(key, StringComparison.OrdinalIgnoreCase)) { - _current = new KeyValuePair("Content-Location", _collection._headers._ContentLocation); - _next = 15; - return true; + if ((_bits & 0x200L) != 0) + { + _bits &= ~0x200L; + _headers._Warning = default(StringValues); + return true; + } + return false; } - HeaderContentMD5: // case 15 - if ((_bits & 0x8000L) != 0) + if (HeaderNames.Expires.Equals(key, StringComparison.OrdinalIgnoreCase)) { - _current = new KeyValuePair("Content-MD5", _collection._headers._ContentMD5); - _next = 16; - return true; + if ((_bits & 0x20000L) != 0) + { + _bits &= ~0x20000L; + _headers._Expires = default(StringValues); + return true; + } + return false; } - HeaderContentRange: // case 16 - if ((_bits & 0x10000L) != 0) + if (HeaderNames.Referer.Equals(key, StringComparison.OrdinalIgnoreCase)) { - _current = new KeyValuePair("Content-Range", _collection._headers._ContentRange); - _next = 17; - return true; + if ((_bits & 0x800000000L) != 0) + { + _bits &= ~0x800000000L; + _headers._Referer = default(StringValues); + return true; + } + return false; } - HeaderExpires: // case 17 - if ((_bits & 0x20000L) != 0) + break; + } + case 8: + { + if (ReferenceEquals(HeaderNames.IfMatch, key)) { - _current = new KeyValuePair("Expires", _collection._headers._Expires); - _next = 18; - return true; + if ((_bits & 0x10000000L) != 0) + { + _bits &= ~0x10000000L; + _headers._IfMatch = default(StringValues); + return true; + } + return false; } - HeaderLastModified: // case 18 - if ((_bits & 0x40000L) != 0) + if (ReferenceEquals(HeaderNames.IfRange, key)) { - _current = new KeyValuePair("Last-Modified", _collection._headers._LastModified); - _next = 19; - return true; + if ((_bits & 0x80000000L) != 0) + { + _bits &= ~0x80000000L; + _headers._IfRange = default(StringValues); + return true; + } + return false; } - HeaderAccept: // case 19 - if ((_bits & 0x80000L) != 0) + + if (HeaderNames.IfMatch.Equals(key, StringComparison.OrdinalIgnoreCase)) { - _current = new KeyValuePair("Accept", _collection._headers._Accept); - _next = 20; - return true; + if ((_bits & 0x10000000L) != 0) + { + _bits &= ~0x10000000L; + _headers._IfMatch = default(StringValues); + return true; + } + return false; } - HeaderAcceptCharset: // case 20 - if ((_bits & 0x100000L) != 0) + if (HeaderNames.IfRange.Equals(key, StringComparison.OrdinalIgnoreCase)) { - _current = new KeyValuePair("Accept-Charset", _collection._headers._AcceptCharset); - _next = 21; - return true; + if ((_bits & 0x80000000L) != 0) + { + _bits &= ~0x80000000L; + _headers._IfRange = default(StringValues); + return true; + } + return false; } - HeaderAcceptEncoding: // case 21 - if ((_bits & 0x200000L) != 0) + break; + } + case 9: + { + if (ReferenceEquals(HeaderNames.Translate, key)) { - _current = new KeyValuePair("Accept-Encoding", _collection._headers._AcceptEncoding); - _next = 22; - return true; + if ((_bits & 0x4000000000L) != 0) + { + _bits &= ~0x4000000000L; + _headers._Translate = default(StringValues); + return true; + } + return false; } - HeaderAcceptLanguage: // case 22 - if ((_bits & 0x400000L) != 0) + + if (HeaderNames.Translate.Equals(key, StringComparison.OrdinalIgnoreCase)) { - _current = new KeyValuePair("Accept-Language", _collection._headers._AcceptLanguage); - _next = 23; - return true; + if ((_bits & 0x4000000000L) != 0) + { + _bits &= ~0x4000000000L; + _headers._Translate = default(StringValues); + return true; + } + return false; } - HeaderAuthorization: // case 23 - if ((_bits & 0x800000L) != 0) + break; + } + case 10: + { + if (ReferenceEquals(HeaderNames.Connection, key)) { - _current = new KeyValuePair("Authorization", _collection._headers._Authorization); - _next = 24; - return true; + if ((_bits & 0x2L) != 0) + { + _bits &= ~0x2L; + _headers._Connection = default(StringValues); + return true; + } + return false; } - HeaderCookie: // case 24 - if ((_bits & 0x1000000L) != 0) + if (ReferenceEquals(HeaderNames.UserAgent, key)) { - _current = new KeyValuePair("Cookie", _collection._headers._Cookie); - _next = 25; - return true; + if ((_bits & 0x8000000000L) != 0) + { + _bits &= ~0x8000000000L; + _headers._UserAgent = default(StringValues); + return true; + } + return false; } - HeaderExpect: // case 25 - if ((_bits & 0x2000000L) != 0) + if (ReferenceEquals(HeaderNames.KeepAlive, key)) { - _current = new KeyValuePair("Expect", _collection._headers._Expect); - _next = 26; - return true; + if ((_bits & 0x8L) != 0) + { + _bits &= ~0x8L; + _headers._KeepAlive = default(StringValues); + return true; + } + return false; } - HeaderFrom: // case 26 - if ((_bits & 0x4000000L) != 0) + if (ReferenceEquals(HeaderNames.RequestId, key)) { - _current = new KeyValuePair("From", _collection._headers._From); - _next = 27; - return true; + if ((_bits & 0x40000000000L) != 0) + { + _bits &= ~0x40000000000L; + _headers._RequestId = default(StringValues); + return true; + } + return false; } - HeaderHost: // case 27 - if ((_bits & 0x8000000L) != 0) + if (ReferenceEquals(HeaderNames.TraceState, key)) { - _current = new KeyValuePair("Host", _collection._headers._Host); - _next = 28; - return true; + if ((_bits & 0x200000000000L) != 0) + { + _bits &= ~0x200000000000L; + _headers._TraceState = default(StringValues); + return true; + } + return false; } - HeaderIfMatch: // case 28 - if ((_bits & 0x10000000L) != 0) + + if (HeaderNames.Connection.Equals(key, StringComparison.OrdinalIgnoreCase)) { - _current = new KeyValuePair("If-Match", _collection._headers._IfMatch); - _next = 29; - return true; + if ((_bits & 0x2L) != 0) + { + _bits &= ~0x2L; + _headers._Connection = default(StringValues); + return true; + } + return false; } - HeaderIfModifiedSince: // case 29 - if ((_bits & 0x20000000L) != 0) + if (HeaderNames.UserAgent.Equals(key, StringComparison.OrdinalIgnoreCase)) { - _current = new KeyValuePair("If-Modified-Since", _collection._headers._IfModifiedSince); - _next = 30; - return true; + if ((_bits & 0x8000000000L) != 0) + { + _bits &= ~0x8000000000L; + _headers._UserAgent = default(StringValues); + return true; + } + return false; } - HeaderIfNoneMatch: // case 30 - if ((_bits & 0x40000000L) != 0) + if (HeaderNames.KeepAlive.Equals(key, StringComparison.OrdinalIgnoreCase)) { - _current = new KeyValuePair("If-None-Match", _collection._headers._IfNoneMatch); - _next = 31; - return true; + if ((_bits & 0x8L) != 0) + { + _bits &= ~0x8L; + _headers._KeepAlive = default(StringValues); + return true; + } + return false; } - HeaderIfRange: // case 31 - if ((_bits & 0x80000000L) != 0) + if (HeaderNames.RequestId.Equals(key, StringComparison.OrdinalIgnoreCase)) { - _current = new KeyValuePair("If-Range", _collection._headers._IfRange); - _next = 32; - return true; + if ((_bits & 0x40000000000L) != 0) + { + _bits &= ~0x40000000000L; + _headers._RequestId = default(StringValues); + return true; + } + return false; } - HeaderIfUnmodifiedSince: // case 32 - if ((_bits & 0x100000000L) != 0) + if (HeaderNames.TraceState.Equals(key, StringComparison.OrdinalIgnoreCase)) { - _current = new KeyValuePair("If-Unmodified-Since", _collection._headers._IfUnmodifiedSince); - _next = 33; - return true; + if ((_bits & 0x200000000000L) != 0) + { + _bits &= ~0x200000000000L; + _headers._TraceState = default(StringValues); + return true; + } + return false; } - HeaderMaxForwards: // case 33 - if ((_bits & 0x200000000L) != 0) + break; + } + case 11: + { + if (ReferenceEquals(HeaderNames.ContentMD5, key)) { - _current = new KeyValuePair("Max-Forwards", _collection._headers._MaxForwards); - _next = 34; - return true; + if ((_bits & 0x8000L) != 0) + { + _bits &= ~0x8000L; + _headers._ContentMD5 = default(StringValues); + return true; + } + return false; } - HeaderProxyAuthorization: // case 34 - if ((_bits & 0x400000000L) != 0) + if (ReferenceEquals(HeaderNames.TraceParent, key)) { - _current = new KeyValuePair("Proxy-Authorization", _collection._headers._ProxyAuthorization); - _next = 35; - return true; + if ((_bits & 0x100000000000L) != 0) + { + _bits &= ~0x100000000000L; + _headers._TraceParent = default(StringValues); + return true; + } + return false; } - HeaderReferer: // case 35 - if ((_bits & 0x800000000L) != 0) + + if (HeaderNames.ContentMD5.Equals(key, StringComparison.OrdinalIgnoreCase)) { - _current = new KeyValuePair("Referer", _collection._headers._Referer); - _next = 36; - return true; + if ((_bits & 0x8000L) != 0) + { + _bits &= ~0x8000L; + _headers._ContentMD5 = default(StringValues); + return true; + } + return false; } - HeaderRange: // case 36 - if ((_bits & 0x1000000000L) != 0) + if (HeaderNames.TraceParent.Equals(key, StringComparison.OrdinalIgnoreCase)) { - _current = new KeyValuePair("Range", _collection._headers._Range); - _next = 37; - return true; + if ((_bits & 0x100000000000L) != 0) + { + _bits &= ~0x100000000000L; + _headers._TraceParent = default(StringValues); + return true; + } + return false; } - HeaderTE: // case 37 - if ((_bits & 0x2000000000L) != 0) + break; + } + case 12: + { + if (ReferenceEquals(HeaderNames.ContentType, key)) { - _current = new KeyValuePair("TE", _collection._headers._TE); - _next = 38; - return true; + if ((_bits & 0x800L) != 0) + { + _bits &= ~0x800L; + _headers._ContentType = default(StringValues); + return true; + } + return false; } - HeaderTranslate: // case 38 - if ((_bits & 0x4000000000L) != 0) + if (ReferenceEquals(HeaderNames.MaxForwards, key)) { - _current = new KeyValuePair("Translate", _collection._headers._Translate); - _next = 39; - return true; + if ((_bits & 0x200000000L) != 0) + { + _bits &= ~0x200000000L; + _headers._MaxForwards = default(StringValues); + return true; + } + return false; } - HeaderUserAgent: // case 39 - if ((_bits & 0x8000000000L) != 0) + + if (HeaderNames.ContentType.Equals(key, StringComparison.OrdinalIgnoreCase)) { - _current = new KeyValuePair("User-Agent", _collection._headers._UserAgent); - _next = 40; - return true; + if ((_bits & 0x800L) != 0) + { + _bits &= ~0x800L; + _headers._ContentType = default(StringValues); + return true; + } + return false; } - HeaderDNT: // case 40 - if ((_bits & 0x10000000000L) != 0) + if (HeaderNames.MaxForwards.Equals(key, StringComparison.OrdinalIgnoreCase)) { - _current = new KeyValuePair("DNT", _collection._headers._DNT); - _next = 41; - return true; + if ((_bits & 0x200000000L) != 0) + { + _bits &= ~0x200000000L; + _headers._MaxForwards = default(StringValues); + return true; + } + return false; } - HeaderUpgradeInsecureRequests: // case 41 - if ((_bits & 0x20000000000L) != 0) - { - _current = new KeyValuePair("Upgrade-Insecure-Requests", _collection._headers._UpgradeInsecureRequests); - _next = 42; - return true; + break; + } + case 13: + { + if (ReferenceEquals(HeaderNames.CacheControl, key)) + { + if ((_bits & 0x1L) != 0) + { + _bits &= ~0x1L; + _headers._CacheControl = default(StringValues); + return true; + } + return false; } - HeaderOrigin: // case 42 - if ((_bits & 0x40000000000L) != 0) + if (ReferenceEquals(HeaderNames.ContentRange, key)) { - _current = new KeyValuePair("Origin", _collection._headers._Origin); - _next = 43; - return true; + if ((_bits & 0x10000L) != 0) + { + _bits &= ~0x10000L; + _headers._ContentRange = default(StringValues); + return true; + } + return false; } - HeaderAccessControlRequestMethod: // case 43 - if ((_bits & 0x80000000000L) != 0) + if (ReferenceEquals(HeaderNames.LastModified, key)) { - _current = new KeyValuePair("Access-Control-Request-Method", _collection._headers._AccessControlRequestMethod); - _next = 44; - return true; + if ((_bits & 0x40000L) != 0) + { + _bits &= ~0x40000L; + _headers._LastModified = default(StringValues); + return true; + } + return false; } - HeaderAccessControlRequestHeaders: // case 44 - if ((_bits & 0x100000000000L) != 0) + if (ReferenceEquals(HeaderNames.Authorization, key)) { - _current = new KeyValuePair("Access-Control-Request-Headers", _collection._headers._AccessControlRequestHeaders); - _next = 45; - return true; + if ((_bits & 0x800000L) != 0) + { + _bits &= ~0x800000L; + _headers._Authorization = default(StringValues); + return true; + } + return false; } - HeaderContentLength: // case 45 - if (_collection._contentLength.HasValue) + if (ReferenceEquals(HeaderNames.IfNoneMatch, key)) { - _current = new KeyValuePair("Content-Length", HeaderUtilities.FormatNonNegativeInt64(_collection._contentLength.Value)); - _next = 46; - return true; + if ((_bits & 0x40000000L) != 0) + { + _bits &= ~0x40000000L; + _headers._IfNoneMatch = default(StringValues); + return true; + } + return false; } - ExtraHeaders: - if (!_hasUnknown || !_unknownEnumerator.MoveNext()) + + if (HeaderNames.CacheControl.Equals(key, StringComparison.OrdinalIgnoreCase)) { - _current = default(KeyValuePair); + if ((_bits & 0x1L) != 0) + { + _bits &= ~0x1L; + _headers._CacheControl = default(StringValues); + return true; + } return false; } - _current = _unknownEnumerator.Current; - return true; + if (HeaderNames.ContentRange.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x10000L) != 0) + { + _bits &= ~0x10000L; + _headers._ContentRange = default(StringValues); + return true; + } + return false; + } + if (HeaderNames.LastModified.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x40000L) != 0) + { + _bits &= ~0x40000L; + _headers._LastModified = default(StringValues); + return true; + } + return false; + } + if (HeaderNames.Authorization.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x800000L) != 0) + { + _bits &= ~0x800000L; + _headers._Authorization = default(StringValues); + return true; + } + return false; + } + if (HeaderNames.IfNoneMatch.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x40000000L) != 0) + { + _bits &= ~0x40000000L; + _headers._IfNoneMatch = default(StringValues); + return true; + } + return false; + } + break; + } + case 14: + { + if (ReferenceEquals(HeaderNames.AcceptCharset, key)) + { + if ((_bits & 0x100000L) != 0) + { + _bits &= ~0x100000L; + _headers._AcceptCharset = default(StringValues); + return true; + } + return false; + } + if (ReferenceEquals(HeaderNames.ContentLength, key)) + { + if (_contentLength.HasValue) + { + _contentLength = null; + return true; + } + return false; + } + + if (HeaderNames.AcceptCharset.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x100000L) != 0) + { + _bits &= ~0x100000L; + _headers._AcceptCharset = default(StringValues); + return true; + } + return false; + } + if (HeaderNames.ContentLength.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if (_contentLength.HasValue) + { + _contentLength = null; + return true; + } + return false; + } + break; + } + case 15: + { + if (ReferenceEquals(HeaderNames.AcceptEncoding, key)) + { + if ((_bits & 0x200000L) != 0) + { + _bits &= ~0x200000L; + _headers._AcceptEncoding = default(StringValues); + return true; + } + return false; + } + if (ReferenceEquals(HeaderNames.AcceptLanguage, key)) + { + if ((_bits & 0x400000L) != 0) + { + _bits &= ~0x400000L; + _headers._AcceptLanguage = default(StringValues); + return true; + } + return false; + } + + if (HeaderNames.AcceptEncoding.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x200000L) != 0) + { + _bits &= ~0x200000L; + _headers._AcceptEncoding = default(StringValues); + return true; + } + return false; + } + if (HeaderNames.AcceptLanguage.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x400000L) != 0) + { + _bits &= ~0x400000L; + _headers._AcceptLanguage = default(StringValues); + return true; + } + return false; + } + break; + } + case 16: + { + if (ReferenceEquals(HeaderNames.ContentEncoding, key)) + { + if ((_bits & 0x1000L) != 0) + { + _bits &= ~0x1000L; + _headers._ContentEncoding = default(StringValues); + return true; + } + return false; + } + if (ReferenceEquals(HeaderNames.ContentLanguage, key)) + { + if ((_bits & 0x2000L) != 0) + { + _bits &= ~0x2000L; + _headers._ContentLanguage = default(StringValues); + return true; + } + return false; + } + if (ReferenceEquals(HeaderNames.ContentLocation, key)) + { + if ((_bits & 0x4000L) != 0) + { + _bits &= ~0x4000L; + _headers._ContentLocation = default(StringValues); + return true; + } + return false; + } + + if (HeaderNames.ContentEncoding.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x1000L) != 0) + { + _bits &= ~0x1000L; + _headers._ContentEncoding = default(StringValues); + return true; + } + return false; + } + if (HeaderNames.ContentLanguage.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x2000L) != 0) + { + _bits &= ~0x2000L; + _headers._ContentLanguage = default(StringValues); + return true; + } + return false; + } + if (HeaderNames.ContentLocation.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x4000L) != 0) + { + _bits &= ~0x4000L; + _headers._ContentLocation = default(StringValues); + return true; + } + return false; + } + break; + } + case 17: + { + if (ReferenceEquals(HeaderNames.TransferEncoding, key)) + { + if ((_bits & 0x40L) != 0) + { + _bits &= ~0x40L; + _headers._TransferEncoding = default(StringValues); + return true; + } + return false; + } + if (ReferenceEquals(HeaderNames.IfModifiedSince, key)) + { + if ((_bits & 0x20000000L) != 0) + { + _bits &= ~0x20000000L; + _headers._IfModifiedSince = default(StringValues); + return true; + } + return false; + } + + if (HeaderNames.TransferEncoding.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x40L) != 0) + { + _bits &= ~0x40L; + _headers._TransferEncoding = default(StringValues); + return true; + } + return false; + } + if (HeaderNames.IfModifiedSince.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x20000000L) != 0) + { + _bits &= ~0x20000000L; + _headers._IfModifiedSince = default(StringValues); + return true; + } + return false; + } + break; + } + case 19: + { + if (ReferenceEquals(HeaderNames.IfUnmodifiedSince, key)) + { + if ((_bits & 0x100000000L) != 0) + { + _bits &= ~0x100000000L; + _headers._IfUnmodifiedSince = default(StringValues); + return true; + } + return false; + } + if (ReferenceEquals(HeaderNames.ProxyAuthorization, key)) + { + if ((_bits & 0x400000000L) != 0) + { + _bits &= ~0x400000000L; + _headers._ProxyAuthorization = default(StringValues); + return true; + } + return false; + } + if (ReferenceEquals(HeaderNames.CorrelationContext, key)) + { + if ((_bits & 0x80000000000L) != 0) + { + _bits &= ~0x80000000000L; + _headers._CorrelationContext = default(StringValues); + return true; + } + return false; + } + + if (HeaderNames.IfUnmodifiedSince.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x100000000L) != 0) + { + _bits &= ~0x100000000L; + _headers._IfUnmodifiedSince = default(StringValues); + return true; + } + return false; + } + if (HeaderNames.ProxyAuthorization.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x400000000L) != 0) + { + _bits &= ~0x400000000L; + _headers._ProxyAuthorization = default(StringValues); + return true; + } + return false; + } + if (HeaderNames.CorrelationContext.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x80000000000L) != 0) + { + _bits &= ~0x80000000000L; + _headers._CorrelationContext = default(StringValues); + return true; + } + return false; + } + break; + } + case 25: + { + if (ReferenceEquals(HeaderNames.UpgradeInsecureRequests, key)) + { + if ((_bits & 0x20000000000L) != 0) + { + _bits &= ~0x20000000000L; + _headers._UpgradeInsecureRequests = default(StringValues); + return true; + } + return false; + } + + if (HeaderNames.UpgradeInsecureRequests.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x20000000000L) != 0) + { + _bits &= ~0x20000000000L; + _headers._UpgradeInsecureRequests = default(StringValues); + return true; + } + return false; + } + break; + } + case 29: + { + if (ReferenceEquals(HeaderNames.AccessControlRequestMethod, key)) + { + if ((_bits & 0x800000000000L) != 0) + { + _bits &= ~0x800000000000L; + _headers._AccessControlRequestMethod = default(StringValues); + return true; + } + return false; + } + + if (HeaderNames.AccessControlRequestMethod.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x800000000000L) != 0) + { + _bits &= ~0x800000000000L; + _headers._AccessControlRequestMethod = default(StringValues); + return true; + } + return false; + } + break; + } + case 30: + { + if (ReferenceEquals(HeaderNames.AccessControlRequestHeaders, key)) + { + if ((_bits & 0x1000000000000L) != 0) + { + _bits &= ~0x1000000000000L; + _headers._AccessControlRequestHeaders = default(StringValues); + return true; + } + return false; + } + + if (HeaderNames.AccessControlRequestHeaders.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x1000000000000L) != 0) + { + _bits &= ~0x1000000000000L; + _headers._AccessControlRequestHeaders = default(StringValues); + return true; + } + return false; + } + break; + } + } + + return RemoveUnknown(key); + } + private void Clear(long bitsToClear) + { + var tempBits = bitsToClear; + + if ((tempBits & 0x2L) != 0) + { + _headers._Connection = default; + if((tempBits & ~0x2L) == 0) + { + return; + } + tempBits &= ~0x2L; + } + + if ((tempBits & 0x80000L) != 0) + { + _headers._Accept = default; + if((tempBits & ~0x80000L) == 0) + { + return; + } + tempBits &= ~0x80000L; + } + + if ((tempBits & 0x8000000L) != 0) + { + _headers._Host = default; + if((tempBits & ~0x8000000L) == 0) + { + return; + } + tempBits &= ~0x8000000L; + } + + if ((tempBits & 0x8000000000L) != 0) + { + _headers._UserAgent = default; + if((tempBits & ~0x8000000000L) == 0) + { + return; + } + tempBits &= ~0x8000000000L; + } + + if ((tempBits & 0x1L) != 0) + { + _headers._CacheControl = default; + if((tempBits & ~0x1L) == 0) + { + return; + } + tempBits &= ~0x1L; + } + + if ((tempBits & 0x4L) != 0) + { + _headers._Date = default; + if((tempBits & ~0x4L) == 0) + { + return; + } + tempBits &= ~0x4L; + } + + if ((tempBits & 0x8L) != 0) + { + _headers._KeepAlive = default; + if((tempBits & ~0x8L) == 0) + { + return; + } + tempBits &= ~0x8L; + } + + if ((tempBits & 0x10L) != 0) + { + _headers._Pragma = default; + if((tempBits & ~0x10L) == 0) + { + return; + } + tempBits &= ~0x10L; + } + + if ((tempBits & 0x20L) != 0) + { + _headers._Trailer = default; + if((tempBits & ~0x20L) == 0) + { + return; + } + tempBits &= ~0x20L; + } + + if ((tempBits & 0x40L) != 0) + { + _headers._TransferEncoding = default; + if((tempBits & ~0x40L) == 0) + { + return; + } + tempBits &= ~0x40L; + } + + if ((tempBits & 0x80L) != 0) + { + _headers._Upgrade = default; + if((tempBits & ~0x80L) == 0) + { + return; + } + tempBits &= ~0x80L; + } + + if ((tempBits & 0x100L) != 0) + { + _headers._Via = default; + if((tempBits & ~0x100L) == 0) + { + return; + } + tempBits &= ~0x100L; + } + + if ((tempBits & 0x200L) != 0) + { + _headers._Warning = default; + if((tempBits & ~0x200L) == 0) + { + return; + } + tempBits &= ~0x200L; + } + + if ((tempBits & 0x400L) != 0) + { + _headers._Allow = default; + if((tempBits & ~0x400L) == 0) + { + return; + } + tempBits &= ~0x400L; + } + + if ((tempBits & 0x800L) != 0) + { + _headers._ContentType = default; + if((tempBits & ~0x800L) == 0) + { + return; + } + tempBits &= ~0x800L; + } + + if ((tempBits & 0x1000L) != 0) + { + _headers._ContentEncoding = default; + if((tempBits & ~0x1000L) == 0) + { + return; + } + tempBits &= ~0x1000L; + } + + if ((tempBits & 0x2000L) != 0) + { + _headers._ContentLanguage = default; + if((tempBits & ~0x2000L) == 0) + { + return; + } + tempBits &= ~0x2000L; + } + + if ((tempBits & 0x4000L) != 0) + { + _headers._ContentLocation = default; + if((tempBits & ~0x4000L) == 0) + { + return; + } + tempBits &= ~0x4000L; + } + + if ((tempBits & 0x8000L) != 0) + { + _headers._ContentMD5 = default; + if((tempBits & ~0x8000L) == 0) + { + return; + } + tempBits &= ~0x8000L; + } + + if ((tempBits & 0x10000L) != 0) + { + _headers._ContentRange = default; + if((tempBits & ~0x10000L) == 0) + { + return; + } + tempBits &= ~0x10000L; + } + + if ((tempBits & 0x20000L) != 0) + { + _headers._Expires = default; + if((tempBits & ~0x20000L) == 0) + { + return; + } + tempBits &= ~0x20000L; + } + + if ((tempBits & 0x40000L) != 0) + { + _headers._LastModified = default; + if((tempBits & ~0x40000L) == 0) + { + return; + } + tempBits &= ~0x40000L; + } + + if ((tempBits & 0x100000L) != 0) + { + _headers._AcceptCharset = default; + if((tempBits & ~0x100000L) == 0) + { + return; + } + tempBits &= ~0x100000L; + } + + if ((tempBits & 0x200000L) != 0) + { + _headers._AcceptEncoding = default; + if((tempBits & ~0x200000L) == 0) + { + return; + } + tempBits &= ~0x200000L; + } + + if ((tempBits & 0x400000L) != 0) + { + _headers._AcceptLanguage = default; + if((tempBits & ~0x400000L) == 0) + { + return; + } + tempBits &= ~0x400000L; + } + + if ((tempBits & 0x800000L) != 0) + { + _headers._Authorization = default; + if((tempBits & ~0x800000L) == 0) + { + return; + } + tempBits &= ~0x800000L; + } + + if ((tempBits & 0x1000000L) != 0) + { + _headers._Cookie = default; + if((tempBits & ~0x1000000L) == 0) + { + return; + } + tempBits &= ~0x1000000L; + } + + if ((tempBits & 0x2000000L) != 0) + { + _headers._Expect = default; + if((tempBits & ~0x2000000L) == 0) + { + return; + } + tempBits &= ~0x2000000L; + } + + if ((tempBits & 0x4000000L) != 0) + { + _headers._From = default; + if((tempBits & ~0x4000000L) == 0) + { + return; + } + tempBits &= ~0x4000000L; + } + + if ((tempBits & 0x10000000L) != 0) + { + _headers._IfMatch = default; + if((tempBits & ~0x10000000L) == 0) + { + return; + } + tempBits &= ~0x10000000L; + } + + if ((tempBits & 0x20000000L) != 0) + { + _headers._IfModifiedSince = default; + if((tempBits & ~0x20000000L) == 0) + { + return; + } + tempBits &= ~0x20000000L; + } + + if ((tempBits & 0x40000000L) != 0) + { + _headers._IfNoneMatch = default; + if((tempBits & ~0x40000000L) == 0) + { + return; + } + tempBits &= ~0x40000000L; + } + + if ((tempBits & 0x80000000L) != 0) + { + _headers._IfRange = default; + if((tempBits & ~0x80000000L) == 0) + { + return; + } + tempBits &= ~0x80000000L; + } + + if ((tempBits & 0x100000000L) != 0) + { + _headers._IfUnmodifiedSince = default; + if((tempBits & ~0x100000000L) == 0) + { + return; + } + tempBits &= ~0x100000000L; + } + + if ((tempBits & 0x200000000L) != 0) + { + _headers._MaxForwards = default; + if((tempBits & ~0x200000000L) == 0) + { + return; + } + tempBits &= ~0x200000000L; + } + + if ((tempBits & 0x400000000L) != 0) + { + _headers._ProxyAuthorization = default; + if((tempBits & ~0x400000000L) == 0) + { + return; + } + tempBits &= ~0x400000000L; + } + + if ((tempBits & 0x800000000L) != 0) + { + _headers._Referer = default; + if((tempBits & ~0x800000000L) == 0) + { + return; + } + tempBits &= ~0x800000000L; + } + + if ((tempBits & 0x1000000000L) != 0) + { + _headers._Range = default; + if((tempBits & ~0x1000000000L) == 0) + { + return; + } + tempBits &= ~0x1000000000L; + } + + if ((tempBits & 0x2000000000L) != 0) + { + _headers._TE = default; + if((tempBits & ~0x2000000000L) == 0) + { + return; + } + tempBits &= ~0x2000000000L; + } + + if ((tempBits & 0x4000000000L) != 0) + { + _headers._Translate = default; + if((tempBits & ~0x4000000000L) == 0) + { + return; + } + tempBits &= ~0x4000000000L; + } + + if ((tempBits & 0x10000000000L) != 0) + { + _headers._DNT = default; + if((tempBits & ~0x10000000000L) == 0) + { + return; + } + tempBits &= ~0x10000000000L; + } + + if ((tempBits & 0x20000000000L) != 0) + { + _headers._UpgradeInsecureRequests = default; + if((tempBits & ~0x20000000000L) == 0) + { + return; + } + tempBits &= ~0x20000000000L; + } + + if ((tempBits & 0x40000000000L) != 0) + { + _headers._RequestId = default; + if((tempBits & ~0x40000000000L) == 0) + { + return; + } + tempBits &= ~0x40000000000L; + } + + if ((tempBits & 0x80000000000L) != 0) + { + _headers._CorrelationContext = default; + if((tempBits & ~0x80000000000L) == 0) + { + return; + } + tempBits &= ~0x80000000000L; + } + + if ((tempBits & 0x100000000000L) != 0) + { + _headers._TraceParent = default; + if((tempBits & ~0x100000000000L) == 0) + { + return; + } + tempBits &= ~0x100000000000L; + } + + if ((tempBits & 0x200000000000L) != 0) + { + _headers._TraceState = default; + if((tempBits & ~0x200000000000L) == 0) + { + return; + } + tempBits &= ~0x200000000000L; + } + + if ((tempBits & 0x400000000000L) != 0) + { + _headers._Origin = default; + if((tempBits & ~0x400000000000L) == 0) + { + return; + } + tempBits &= ~0x400000000000L; + } + + if ((tempBits & 0x800000000000L) != 0) + { + _headers._AccessControlRequestMethod = default; + if((tempBits & ~0x800000000000L) == 0) + { + return; + } + tempBits &= ~0x800000000000L; + } + + if ((tempBits & 0x1000000000000L) != 0) + { + _headers._AccessControlRequestHeaders = default; + if((tempBits & ~0x1000000000000L) == 0) + { + return; + } + tempBits &= ~0x1000000000000L; + } + + } + + protected override bool CopyToFast(KeyValuePair[] array, int arrayIndex) + { + if (arrayIndex < 0) + { + return false; + } + + if ((_bits & 0x1L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.CacheControl, _headers._CacheControl); + ++arrayIndex; + } + if ((_bits & 0x2L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.Connection, _headers._Connection); + ++arrayIndex; + } + if ((_bits & 0x4L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.Date, _headers._Date); + ++arrayIndex; + } + if ((_bits & 0x8L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.KeepAlive, _headers._KeepAlive); + ++arrayIndex; + } + if ((_bits & 0x10L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.Pragma, _headers._Pragma); + ++arrayIndex; + } + if ((_bits & 0x20L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.Trailer, _headers._Trailer); + ++arrayIndex; + } + if ((_bits & 0x40L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.TransferEncoding, _headers._TransferEncoding); + ++arrayIndex; + } + if ((_bits & 0x80L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.Upgrade, _headers._Upgrade); + ++arrayIndex; + } + if ((_bits & 0x100L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.Via, _headers._Via); + ++arrayIndex; + } + if ((_bits & 0x200L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.Warning, _headers._Warning); + ++arrayIndex; + } + if ((_bits & 0x400L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.Allow, _headers._Allow); + ++arrayIndex; + } + if ((_bits & 0x800L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.ContentType, _headers._ContentType); + ++arrayIndex; + } + if ((_bits & 0x1000L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.ContentEncoding, _headers._ContentEncoding); + ++arrayIndex; + } + if ((_bits & 0x2000L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.ContentLanguage, _headers._ContentLanguage); + ++arrayIndex; + } + if ((_bits & 0x4000L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.ContentLocation, _headers._ContentLocation); + ++arrayIndex; + } + if ((_bits & 0x8000L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.ContentMD5, _headers._ContentMD5); + ++arrayIndex; + } + if ((_bits & 0x10000L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.ContentRange, _headers._ContentRange); + ++arrayIndex; + } + if ((_bits & 0x20000L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.Expires, _headers._Expires); + ++arrayIndex; + } + if ((_bits & 0x40000L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.LastModified, _headers._LastModified); + ++arrayIndex; + } + if ((_bits & 0x80000L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.Accept, _headers._Accept); + ++arrayIndex; + } + if ((_bits & 0x100000L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.AcceptCharset, _headers._AcceptCharset); + ++arrayIndex; + } + if ((_bits & 0x200000L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.AcceptEncoding, _headers._AcceptEncoding); + ++arrayIndex; + } + if ((_bits & 0x400000L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.AcceptLanguage, _headers._AcceptLanguage); + ++arrayIndex; + } + if ((_bits & 0x800000L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.Authorization, _headers._Authorization); + ++arrayIndex; + } + if ((_bits & 0x1000000L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.Cookie, _headers._Cookie); + ++arrayIndex; + } + if ((_bits & 0x2000000L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.Expect, _headers._Expect); + ++arrayIndex; + } + if ((_bits & 0x4000000L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.From, _headers._From); + ++arrayIndex; + } + if ((_bits & 0x8000000L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.Host, _headers._Host); + ++arrayIndex; + } + if ((_bits & 0x10000000L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.IfMatch, _headers._IfMatch); + ++arrayIndex; + } + if ((_bits & 0x20000000L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.IfModifiedSince, _headers._IfModifiedSince); + ++arrayIndex; + } + if ((_bits & 0x40000000L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.IfNoneMatch, _headers._IfNoneMatch); + ++arrayIndex; + } + if ((_bits & 0x80000000L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.IfRange, _headers._IfRange); + ++arrayIndex; + } + if ((_bits & 0x100000000L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.IfUnmodifiedSince, _headers._IfUnmodifiedSince); + ++arrayIndex; + } + if ((_bits & 0x200000000L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.MaxForwards, _headers._MaxForwards); + ++arrayIndex; + } + if ((_bits & 0x400000000L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.ProxyAuthorization, _headers._ProxyAuthorization); + ++arrayIndex; + } + if ((_bits & 0x800000000L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.Referer, _headers._Referer); + ++arrayIndex; + } + if ((_bits & 0x1000000000L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.Range, _headers._Range); + ++arrayIndex; + } + if ((_bits & 0x2000000000L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.TE, _headers._TE); + ++arrayIndex; + } + if ((_bits & 0x4000000000L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.Translate, _headers._Translate); + ++arrayIndex; + } + if ((_bits & 0x8000000000L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.UserAgent, _headers._UserAgent); + ++arrayIndex; + } + if ((_bits & 0x10000000000L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.DNT, _headers._DNT); + ++arrayIndex; + } + if ((_bits & 0x20000000000L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.UpgradeInsecureRequests, _headers._UpgradeInsecureRequests); + ++arrayIndex; + } + if ((_bits & 0x40000000000L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.RequestId, _headers._RequestId); + ++arrayIndex; + } + if ((_bits & 0x80000000000L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.CorrelationContext, _headers._CorrelationContext); + ++arrayIndex; + } + if ((_bits & 0x100000000000L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.TraceParent, _headers._TraceParent); + ++arrayIndex; + } + if ((_bits & 0x200000000000L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.TraceState, _headers._TraceState); + ++arrayIndex; + } + if ((_bits & 0x400000000000L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.Origin, _headers._Origin); + ++arrayIndex; + } + if ((_bits & 0x800000000000L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.AccessControlRequestMethod, _headers._AccessControlRequestMethod); + ++arrayIndex; + } + if ((_bits & 0x1000000000000L) != 0) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.AccessControlRequestHeaders, _headers._AccessControlRequestHeaders); + ++arrayIndex; + } + if (_contentLength.HasValue) + { + if (arrayIndex == array.Length) + { + return false; + } + array[arrayIndex] = new KeyValuePair(HeaderNames.ContentLength, HeaderUtilities.FormatNonNegativeInt64(_contentLength.Value)); + ++arrayIndex; + } + ((ICollection>)MaybeUnknown)?.CopyTo(array, arrayIndex); + + return true; + } + + [MethodImpl(MethodImplOptions.AggressiveOptimization)] + public unsafe void Append(Span name, Span value) + { + ref byte nameStart = ref MemoryMarshal.GetReference(name); + ref StringValues values = ref Unsafe.AsRef(null); + var flag = 0L; + + // Does the name matched any "known" headers + switch (name.Length) + { + case 2: + if (((Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfu) == 0x4554u)) + { + flag = 0x2000000000L; + values = ref _headers._TE; + } + break; + case 3: + var firstTerm3 = (Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfu); + if ((firstTerm3 == 0x4e44u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)2) & 0xdfu) == 0x54u)) + { + flag = 0x10000000000L; + values = ref _headers._DNT; + } + else if ((firstTerm3 == 0x4956u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)2) & 0xdfu) == 0x41u)) + { + flag = 0x100L; + values = ref _headers._Via; + } + break; + case 4: + var firstTerm4 = (Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfdfdfu); + if ((firstTerm4 == 0x54534f48u)) + { + flag = 0x8000000L; + values = ref _headers._Host; + } + else if ((firstTerm4 == 0x45544144u)) + { + flag = 0x4L; + values = ref _headers._Date; + } + else if ((firstTerm4 == 0x4d4f5246u)) + { + flag = 0x4000000L; + values = ref _headers._From; + } + break; + case 5: + var firstTerm5 = (Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfdfdfu); + if ((firstTerm5 == 0x4f4c4c41u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)4) & 0xdfu) == 0x57u)) + { + flag = 0x400L; + values = ref _headers._Allow; + } + else if ((firstTerm5 == 0x474e4152u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)4) & 0xdfu) == 0x45u)) + { + flag = 0x1000000000L; + values = ref _headers._Range; + } + break; + case 6: + var firstTerm6 = (Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfdfdfu); + if ((firstTerm6 == 0x45434341u) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(ushort)))) & 0xdfdfu) == 0x5450u)) + { + flag = 0x80000L; + values = ref _headers._Accept; + } + else if ((firstTerm6 == 0x4b4f4f43u) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(ushort)))) & 0xdfdfu) == 0x4549u)) + { + flag = 0x1000000L; + values = ref _headers._Cookie; + } + else if ((firstTerm6 == 0x45505845u) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(ushort)))) & 0xdfdfu) == 0x5443u)) + { + flag = 0x2000000L; + values = ref _headers._Expect; + } + else if ((firstTerm6 == 0x4749524fu) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(ushort)))) & 0xdfdfu) == 0x4e49u)) + { + flag = 0x400000000000L; + values = ref _headers._Origin; + } + else if ((firstTerm6 == 0x47415250u) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(ushort)))) & 0xdfdfu) == 0x414du)) + { + flag = 0x10L; + values = ref _headers._Pragma; + } + break; + case 7: + var firstTerm7 = (Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfdfdfu); + if ((firstTerm7 == 0x49505845u) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(ushort)))) & 0xdfdfu) == 0x4552u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)6) & 0xdfu) == 0x53u)) + { + flag = 0x20000L; + values = ref _headers._Expires; + } + else if ((firstTerm7 == 0x45464552u) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(ushort)))) & 0xdfdfu) == 0x4552u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)6) & 0xdfu) == 0x52u)) + { + flag = 0x800000000L; + values = ref _headers._Referer; + } + else if ((firstTerm7 == 0x49415254u) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(ushort)))) & 0xdfdfu) == 0x454cu) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)6) & 0xdfu) == 0x52u)) + { + flag = 0x20L; + values = ref _headers._Trailer; + } + else if ((firstTerm7 == 0x52475055u) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(ushort)))) & 0xdfdfu) == 0x4441u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)6) & 0xdfu) == 0x45u)) + { + flag = 0x80L; + values = ref _headers._Upgrade; + } + else if ((firstTerm7 == 0x4e524157u) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(ushort)))) & 0xdfdfu) == 0x4e49u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)6) & 0xdfu) == 0x47u)) + { + flag = 0x200L; + values = ref _headers._Warning; + } + break; + case 8: + var firstTerm8 = (Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfdfdfdfffdfdfuL); + if ((firstTerm8 == 0x484354414d2d4649uL)) + { + flag = 0x10000000L; + values = ref _headers._IfMatch; + } + else if ((firstTerm8 == 0x45474e41522d4649uL)) + { + flag = 0x80000000L; + values = ref _headers._IfRange; + } + break; + case 9: + if (((Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfdfdfdfdfdfdfuL) == 0x54414c534e415254uL) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)8) & 0xdfu) == 0x45u)) + { + flag = 0x4000000000L; + values = ref _headers._Translate; + } + break; + case 10: + if (((Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfdfdfdfdfdfdfuL) == 0x495443454e4e4f43uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(4 * sizeof(ushort)))) & 0xdfdfu) == 0x4e4fu)) + { + flag = 0x2L; + values = ref _headers._Connection; + } + else if (((Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfdfffdfdfdfdfuL) == 0x4547412d52455355uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(4 * sizeof(ushort)))) & 0xdfdfu) == 0x544eu)) + { + flag = 0x8000000000L; + values = ref _headers._UserAgent; + } + else if (((Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfdfffdfdfdfdfuL) == 0x494c412d5045454buL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(4 * sizeof(ushort)))) & 0xdfdfu) == 0x4556u)) + { + flag = 0x8L; + values = ref _headers._KeepAlive; + } + else if (((Unsafe.ReadUnaligned(ref nameStart) & 0xffdfdfdfdfdfdfdfuL) == 0x2d54534555514552uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(4 * sizeof(ushort)))) & 0xdfdfu) == 0x4449u)) + { + flag = 0x40000000000L; + values = ref _headers._RequestId; + } + else if (((Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfdfdfdfdfdfdfuL) == 0x4154534543415254uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(4 * sizeof(ushort)))) & 0xdfdfu) == 0x4554u)) + { + flag = 0x200000000000L; + values = ref _headers._TraceState; + } + break; + case 11: + if (((Unsafe.ReadUnaligned(ref nameStart) & 0xffdfdfdfdfdfdfdfuL) == 0x2d544e45544e4f43uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(4 * sizeof(ushort)))) & 0xdfdfu) == 0x444du) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)10) & 0xffu) == 0x35u)) + { + flag = 0x8000L; + values = ref _headers._ContentMD5; + } + else if (((Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfdfdfdfdfdfdfuL) == 0x5241504543415254uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(4 * sizeof(ushort)))) & 0xdfdfu) == 0x4e45u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)10) & 0xdfu) == 0x54u)) + { + flag = 0x100000000000L; + values = ref _headers._TraceParent; + } + break; + case 12: + if (((Unsafe.ReadUnaligned(ref nameStart) & 0xffdfdfdfdfdfdfdfuL) == 0x2d544e45544e4f43uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(uint)))) & 0xdfdfdfdfu) == 0x45505954u)) + { + flag = 0x800L; + values = ref _headers._ContentType; + } + else if (((Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfdfdfffdfdfdfuL) == 0x57524f462d58414duL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(uint)))) & 0xdfdfdfdfu) == 0x53445241u)) + { + flag = 0x200000000L; + values = ref _headers._MaxForwards; + } + break; + case 13: + if (((Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfdfdfdfdfdfdfuL) == 0x5a49524f48545541uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(uint)))) & 0xdfdfdfdfu) == 0x4f495441u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)12) & 0xdfu) == 0x4eu)) + { + flag = 0x800000L; + values = ref _headers._Authorization; + } + else if (((Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfffdfdfdfdfdfuL) == 0x4f432d4548434143uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(uint)))) & 0xdfdfdfdfu) == 0x4f52544eu) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)12) & 0xdfu) == 0x4cu)) + { + flag = 0x1L; + values = ref _headers._CacheControl; + } + else if (((Unsafe.ReadUnaligned(ref nameStart) & 0xffdfdfdfdfdfdfdfuL) == 0x2d544e45544e4f43uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(uint)))) & 0xdfdfdfdfu) == 0x474e4152u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)12) & 0xdfu) == 0x45u)) + { + flag = 0x10000L; + values = ref _headers._ContentRange; + } + else if (((Unsafe.ReadUnaligned(ref nameStart) & 0xffdfdfdfdfffdfdfuL) == 0x2d454e4f4e2d4649uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(uint)))) & 0xdfdfdfdfu) == 0x4354414du) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)12) & 0xdfu) == 0x48u)) + { + flag = 0x40000000L; + values = ref _headers._IfNoneMatch; + } + else if (((Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfdfffdfdfdfdfuL) == 0x444f4d2d5453414cuL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(uint)))) & 0xdfdfdfdfu) == 0x45494649u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)12) & 0xdfu) == 0x44u)) + { + flag = 0x40000L; + values = ref _headers._LastModified; + } + break; + case 14: + if (((Unsafe.ReadUnaligned(ref nameStart) & 0xdfffdfdfdfdfdfdfuL) == 0x432d545045434341uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(uint)))) & 0xdfdfdfdfu) == 0x53524148u) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(6 * sizeof(ushort)))) & 0xdfdfu) == 0x5445u)) + { + flag = 0x100000L; + values = ref _headers._AcceptCharset; + } + else if (((Unsafe.ReadUnaligned(ref nameStart) & 0xffdfdfdfdfdfdfdfuL) == 0x2d544e45544e4f43uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(uint)))) & 0xdfdfdfdfu) == 0x474e454cu) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(6 * sizeof(ushort)))) & 0xdfdfu) == 0x4854u)) + { + AppendContentLength(value); + return; + } + break; + case 15: + var firstTerm15 = (Unsafe.ReadUnaligned(ref nameStart) & 0xdfffdfdfdfdfdfdfuL); + if ((firstTerm15 == 0x452d545045434341uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(uint)))) & 0xdfdfdfdfu) == 0x444f434eu) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(6 * sizeof(ushort)))) & 0xdfdfu) == 0x4e49u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)14) & 0xdfu) == 0x47u)) + { + flag = 0x200000L; + values = ref _headers._AcceptEncoding; + } + else if ((firstTerm15 == 0x4c2d545045434341uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(uint)))) & 0xdfdfdfdfu) == 0x55474e41u) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(6 * sizeof(ushort)))) & 0xdfdfu) == 0x4741u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)14) & 0xdfu) == 0x45u)) + { + flag = 0x400000L; + values = ref _headers._AcceptLanguage; + } + break; + case 16: + var firstTerm16 = (Unsafe.ReadUnaligned(ref nameStart) & 0xffdfdfdfdfdfdfdfuL); + if ((firstTerm16 == 0x2d544e45544e4f43uL)) + { + if (((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)sizeof(ulong))) & 0xdfdfdfdfdfdfdfdfuL) == 0x474e49444f434e45uL)) + { + flag = 0x1000L; + values = ref _headers._ContentEncoding; + } + else if (((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)sizeof(ulong))) & 0xdfdfdfdfdfdfdfdfuL) == 0x45474155474e414cuL)) + { + flag = 0x2000L; + values = ref _headers._ContentLanguage; + } + else if (((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)sizeof(ulong))) & 0xdfdfdfdfdfdfdfdfuL) == 0x4e4f495441434f4cuL)) + { + flag = 0x4000L; + values = ref _headers._ContentLocation; + } + } + break; + case 17: + if (((Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfdfdfdfffdfdfuL) == 0x4649444f4d2d4649uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)sizeof(ulong))) & 0xdfdfdfdfffdfdfdfuL) == 0x434e49532d444549uL) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)16) & 0xdfu) == 0x45u)) + { + flag = 0x20000000L; + values = ref _headers._IfModifiedSince; + } + else if (((Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfdfdfdfdfdfdfuL) == 0x524546534e415254uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)sizeof(ulong))) & 0xdfdfdfdfdfdfdfffuL) == 0x4e49444f434e452duL) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)16) & 0xdfu) == 0x47u)) + { + flag = 0x40L; + values = ref _headers._TransferEncoding; + } + break; + case 19: + if (((Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfdfdfdfdfdfdfuL) == 0x54414c4552524f43uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)sizeof(ulong))) & 0xdfdfdfdfffdfdfdfuL) == 0x544e4f432d4e4f49uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(8 * sizeof(ushort)))) & 0xdfdfu) == 0x5845u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)18) & 0xdfu) == 0x54u)) + { + flag = 0x80000000000L; + values = ref _headers._CorrelationContext; + } + else if (((Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfdfdfdfffdfdfuL) == 0x444f4d4e552d4649uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)sizeof(ulong))) & 0xdfdfffdfdfdfdfdfuL) == 0x49532d4445494649uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(8 * sizeof(ushort)))) & 0xdfdfu) == 0x434eu) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)18) & 0xdfu) == 0x45u)) + { + flag = 0x100000000L; + values = ref _headers._IfUnmodifiedSince; + } + else if (((Unsafe.ReadUnaligned(ref nameStart) & 0xdfdfffdfdfdfdfdfuL) == 0x55412d59584f5250uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)sizeof(ulong))) & 0xdfdfdfdfdfdfdfdfuL) == 0x54415a49524f4854uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(8 * sizeof(ushort)))) & 0xdfdfu) == 0x4f49u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)18) & 0xdfu) == 0x4eu)) + { + flag = 0x400000000L; + values = ref _headers._ProxyAuthorization; + } + break; + case 25: + if (((Unsafe.ReadUnaligned(ref nameStart) & 0xffdfdfdfdfdfdfdfuL) == 0x2d45444152475055uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)sizeof(ulong))) & 0xdfdfdfdfdfdfdfdfuL) == 0x4552554345534e49uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(ulong)))) & 0xdfdfdfdfdfdfdfffuL) == 0x545345555145522duL) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)24) & 0xdfu) == 0x53u)) + { + flag = 0x20000000000L; + values = ref _headers._UpgradeInsecureRequests; + } + break; + case 29: + if (((Unsafe.ReadUnaligned(ref nameStart) & 0xdfffdfdfdfdfdfdfuL) == 0x432d535345434341uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)sizeof(ulong))) & 0xdfffdfdfdfdfdfdfuL) == 0x522d4c4f52544e4fuL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(ulong)))) & 0xdfffdfdfdfdfdfdfuL) == 0x4d2d545345555145uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(6 * sizeof(uint)))) & 0xdfdfdfdfu) == 0x4f485445u) && ((Unsafe.AddByteOffset(ref nameStart, (IntPtr)28) & 0xdfu) == 0x44u)) + { + flag = 0x800000000000L; + values = ref _headers._AccessControlRequestMethod; + } + break; + case 30: + if (((Unsafe.ReadUnaligned(ref nameStart) & 0xdfffdfdfdfdfdfdfuL) == 0x432d535345434341uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)sizeof(ulong))) & 0xdfffdfdfdfdfdfdfuL) == 0x522d4c4f52544e4fuL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(2 * sizeof(ulong)))) & 0xdfffdfdfdfdfdfdfuL) == 0x482d545345555145uL) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(6 * sizeof(uint)))) & 0xdfdfdfdfu) == 0x45444145u) && ((Unsafe.ReadUnaligned(ref Unsafe.AddByteOffset(ref nameStart, (IntPtr)(14 * sizeof(ushort)))) & 0xdfdfu) == 0x5352u)) + { + flag = 0x1000000000000L; + values = ref _headers._AccessControlRequestHeaders; + } + break; + } + + if (flag != 0) + { + // Matched a known header + if ((_previousBits & flag) != 0) + { + // Had a previous string for this header, mark it as used so we don't clear it OnHeadersComplete or consider it if we get a second header + _previousBits ^= flag; + + // We will only reuse this header if there was only one previous header + if (values.Count == 1) + { + var previousValue = values.ToString(); + // Check lengths are the same, then if the bytes were converted to an ascii string if they would be the same. + // We do not consider Utf8 headers for reuse. + if (previousValue.Length == value.Length && + StringUtilities.BytesOrdinalEqualsStringAndAscii(previousValue, value)) + { + // The previous string matches what the bytes would convert to, so we will just use that one. + _bits |= flag; + return; + } + } + } + + // We didn't have a previous matching header value, or have already added a header, so get the string for this value. + var valueStr = value.GetAsciiOrUTF8StringNonNullCharacters(); + if ((_bits & flag) == 0) + { + // We didn't already have a header set, so add a new one. + _bits |= flag; + values = new StringValues(valueStr); + } + else + { + // We already had a header set, so concatenate the new one. + values = AppendValue(values, valueStr); + } + } + else + { + // The header was not one of the "known" headers. + // Convert value to string first, because passing two spans causes 8 bytes stack zeroing in + // this method with rep stosd, which is slower than necessary. + var valueStr = value.GetAsciiOrUTF8StringNonNullCharacters(); + AppendUnknownHeaders(name, valueStr); + } + } + + private struct HeaderReferences + { + public StringValues _CacheControl; + public StringValues _Connection; + public StringValues _Date; + public StringValues _KeepAlive; + public StringValues _Pragma; + public StringValues _Trailer; + public StringValues _TransferEncoding; + public StringValues _Upgrade; + public StringValues _Via; + public StringValues _Warning; + public StringValues _Allow; + public StringValues _ContentType; + public StringValues _ContentEncoding; + public StringValues _ContentLanguage; + public StringValues _ContentLocation; + public StringValues _ContentMD5; + public StringValues _ContentRange; + public StringValues _Expires; + public StringValues _LastModified; + public StringValues _Accept; + public StringValues _AcceptCharset; + public StringValues _AcceptEncoding; + public StringValues _AcceptLanguage; + public StringValues _Authorization; + public StringValues _Cookie; + public StringValues _Expect; + public StringValues _From; + public StringValues _Host; + public StringValues _IfMatch; + public StringValues _IfModifiedSince; + public StringValues _IfNoneMatch; + public StringValues _IfRange; + public StringValues _IfUnmodifiedSince; + public StringValues _MaxForwards; + public StringValues _ProxyAuthorization; + public StringValues _Referer; + public StringValues _Range; + public StringValues _TE; + public StringValues _Translate; + public StringValues _UserAgent; + public StringValues _DNT; + public StringValues _UpgradeInsecureRequests; + public StringValues _RequestId; + public StringValues _CorrelationContext; + public StringValues _TraceParent; + public StringValues _TraceState; + public StringValues _Origin; + public StringValues _AccessControlRequestMethod; + public StringValues _AccessControlRequestHeaders; + + } + + public partial struct Enumerator + { + // Compiled to Jump table + public bool MoveNext() + { + switch (_next) + { + case 0: + goto HeaderCacheControl; + case 1: + goto HeaderConnection; + case 2: + goto HeaderDate; + case 3: + goto HeaderKeepAlive; + case 4: + goto HeaderPragma; + case 5: + goto HeaderTrailer; + case 6: + goto HeaderTransferEncoding; + case 7: + goto HeaderUpgrade; + case 8: + goto HeaderVia; + case 9: + goto HeaderWarning; + case 10: + goto HeaderAllow; + case 11: + goto HeaderContentType; + case 12: + goto HeaderContentEncoding; + case 13: + goto HeaderContentLanguage; + case 14: + goto HeaderContentLocation; + case 15: + goto HeaderContentMD5; + case 16: + goto HeaderContentRange; + case 17: + goto HeaderExpires; + case 18: + goto HeaderLastModified; + case 19: + goto HeaderAccept; + case 20: + goto HeaderAcceptCharset; + case 21: + goto HeaderAcceptEncoding; + case 22: + goto HeaderAcceptLanguage; + case 23: + goto HeaderAuthorization; + case 24: + goto HeaderCookie; + case 25: + goto HeaderExpect; + case 26: + goto HeaderFrom; + case 27: + goto HeaderHost; + case 28: + goto HeaderIfMatch; + case 29: + goto HeaderIfModifiedSince; + case 30: + goto HeaderIfNoneMatch; + case 31: + goto HeaderIfRange; + case 32: + goto HeaderIfUnmodifiedSince; + case 33: + goto HeaderMaxForwards; + case 34: + goto HeaderProxyAuthorization; + case 35: + goto HeaderReferer; + case 36: + goto HeaderRange; + case 37: + goto HeaderTE; + case 38: + goto HeaderTranslate; + case 39: + goto HeaderUserAgent; + case 40: + goto HeaderDNT; + case 41: + goto HeaderUpgradeInsecureRequests; + case 42: + goto HeaderRequestId; + case 43: + goto HeaderCorrelationContext; + case 44: + goto HeaderTraceParent; + case 45: + goto HeaderTraceState; + case 46: + goto HeaderOrigin; + case 47: + goto HeaderAccessControlRequestMethod; + case 48: + goto HeaderAccessControlRequestHeaders; + case 49: + goto HeaderContentLength; + default: + goto ExtraHeaders; + } + + HeaderCacheControl: // case 0 + if ((_bits & 0x1L) != 0) + { + _current = new KeyValuePair(HeaderNames.CacheControl, _collection._headers._CacheControl); + _next = 1; + return true; + } + HeaderConnection: // case 1 + if ((_bits & 0x2L) != 0) + { + _current = new KeyValuePair(HeaderNames.Connection, _collection._headers._Connection); + _next = 2; + return true; + } + HeaderDate: // case 2 + if ((_bits & 0x4L) != 0) + { + _current = new KeyValuePair(HeaderNames.Date, _collection._headers._Date); + _next = 3; + return true; + } + HeaderKeepAlive: // case 3 + if ((_bits & 0x8L) != 0) + { + _current = new KeyValuePair(HeaderNames.KeepAlive, _collection._headers._KeepAlive); + _next = 4; + return true; + } + HeaderPragma: // case 4 + if ((_bits & 0x10L) != 0) + { + _current = new KeyValuePair(HeaderNames.Pragma, _collection._headers._Pragma); + _next = 5; + return true; + } + HeaderTrailer: // case 5 + if ((_bits & 0x20L) != 0) + { + _current = new KeyValuePair(HeaderNames.Trailer, _collection._headers._Trailer); + _next = 6; + return true; + } + HeaderTransferEncoding: // case 6 + if ((_bits & 0x40L) != 0) + { + _current = new KeyValuePair(HeaderNames.TransferEncoding, _collection._headers._TransferEncoding); + _next = 7; + return true; + } + HeaderUpgrade: // case 7 + if ((_bits & 0x80L) != 0) + { + _current = new KeyValuePair(HeaderNames.Upgrade, _collection._headers._Upgrade); + _next = 8; + return true; + } + HeaderVia: // case 8 + if ((_bits & 0x100L) != 0) + { + _current = new KeyValuePair(HeaderNames.Via, _collection._headers._Via); + _next = 9; + return true; + } + HeaderWarning: // case 9 + if ((_bits & 0x200L) != 0) + { + _current = new KeyValuePair(HeaderNames.Warning, _collection._headers._Warning); + _next = 10; + return true; + } + HeaderAllow: // case 10 + if ((_bits & 0x400L) != 0) + { + _current = new KeyValuePair(HeaderNames.Allow, _collection._headers._Allow); + _next = 11; + return true; + } + HeaderContentType: // case 11 + if ((_bits & 0x800L) != 0) + { + _current = new KeyValuePair(HeaderNames.ContentType, _collection._headers._ContentType); + _next = 12; + return true; + } + HeaderContentEncoding: // case 12 + if ((_bits & 0x1000L) != 0) + { + _current = new KeyValuePair(HeaderNames.ContentEncoding, _collection._headers._ContentEncoding); + _next = 13; + return true; + } + HeaderContentLanguage: // case 13 + if ((_bits & 0x2000L) != 0) + { + _current = new KeyValuePair(HeaderNames.ContentLanguage, _collection._headers._ContentLanguage); + _next = 14; + return true; + } + HeaderContentLocation: // case 14 + if ((_bits & 0x4000L) != 0) + { + _current = new KeyValuePair(HeaderNames.ContentLocation, _collection._headers._ContentLocation); + _next = 15; + return true; + } + HeaderContentMD5: // case 15 + if ((_bits & 0x8000L) != 0) + { + _current = new KeyValuePair(HeaderNames.ContentMD5, _collection._headers._ContentMD5); + _next = 16; + return true; + } + HeaderContentRange: // case 16 + if ((_bits & 0x10000L) != 0) + { + _current = new KeyValuePair(HeaderNames.ContentRange, _collection._headers._ContentRange); + _next = 17; + return true; + } + HeaderExpires: // case 17 + if ((_bits & 0x20000L) != 0) + { + _current = new KeyValuePair(HeaderNames.Expires, _collection._headers._Expires); + _next = 18; + return true; + } + HeaderLastModified: // case 18 + if ((_bits & 0x40000L) != 0) + { + _current = new KeyValuePair(HeaderNames.LastModified, _collection._headers._LastModified); + _next = 19; + return true; + } + HeaderAccept: // case 19 + if ((_bits & 0x80000L) != 0) + { + _current = new KeyValuePair(HeaderNames.Accept, _collection._headers._Accept); + _next = 20; + return true; + } + HeaderAcceptCharset: // case 20 + if ((_bits & 0x100000L) != 0) + { + _current = new KeyValuePair(HeaderNames.AcceptCharset, _collection._headers._AcceptCharset); + _next = 21; + return true; + } + HeaderAcceptEncoding: // case 21 + if ((_bits & 0x200000L) != 0) + { + _current = new KeyValuePair(HeaderNames.AcceptEncoding, _collection._headers._AcceptEncoding); + _next = 22; + return true; + } + HeaderAcceptLanguage: // case 22 + if ((_bits & 0x400000L) != 0) + { + _current = new KeyValuePair(HeaderNames.AcceptLanguage, _collection._headers._AcceptLanguage); + _next = 23; + return true; + } + HeaderAuthorization: // case 23 + if ((_bits & 0x800000L) != 0) + { + _current = new KeyValuePair(HeaderNames.Authorization, _collection._headers._Authorization); + _next = 24; + return true; + } + HeaderCookie: // case 24 + if ((_bits & 0x1000000L) != 0) + { + _current = new KeyValuePair(HeaderNames.Cookie, _collection._headers._Cookie); + _next = 25; + return true; + } + HeaderExpect: // case 25 + if ((_bits & 0x2000000L) != 0) + { + _current = new KeyValuePair(HeaderNames.Expect, _collection._headers._Expect); + _next = 26; + return true; + } + HeaderFrom: // case 26 + if ((_bits & 0x4000000L) != 0) + { + _current = new KeyValuePair(HeaderNames.From, _collection._headers._From); + _next = 27; + return true; + } + HeaderHost: // case 27 + if ((_bits & 0x8000000L) != 0) + { + _current = new KeyValuePair(HeaderNames.Host, _collection._headers._Host); + _next = 28; + return true; + } + HeaderIfMatch: // case 28 + if ((_bits & 0x10000000L) != 0) + { + _current = new KeyValuePair(HeaderNames.IfMatch, _collection._headers._IfMatch); + _next = 29; + return true; + } + HeaderIfModifiedSince: // case 29 + if ((_bits & 0x20000000L) != 0) + { + _current = new KeyValuePair(HeaderNames.IfModifiedSince, _collection._headers._IfModifiedSince); + _next = 30; + return true; + } + HeaderIfNoneMatch: // case 30 + if ((_bits & 0x40000000L) != 0) + { + _current = new KeyValuePair(HeaderNames.IfNoneMatch, _collection._headers._IfNoneMatch); + _next = 31; + return true; + } + HeaderIfRange: // case 31 + if ((_bits & 0x80000000L) != 0) + { + _current = new KeyValuePair(HeaderNames.IfRange, _collection._headers._IfRange); + _next = 32; + return true; + } + HeaderIfUnmodifiedSince: // case 32 + if ((_bits & 0x100000000L) != 0) + { + _current = new KeyValuePair(HeaderNames.IfUnmodifiedSince, _collection._headers._IfUnmodifiedSince); + _next = 33; + return true; + } + HeaderMaxForwards: // case 33 + if ((_bits & 0x200000000L) != 0) + { + _current = new KeyValuePair(HeaderNames.MaxForwards, _collection._headers._MaxForwards); + _next = 34; + return true; + } + HeaderProxyAuthorization: // case 34 + if ((_bits & 0x400000000L) != 0) + { + _current = new KeyValuePair(HeaderNames.ProxyAuthorization, _collection._headers._ProxyAuthorization); + _next = 35; + return true; + } + HeaderReferer: // case 35 + if ((_bits & 0x800000000L) != 0) + { + _current = new KeyValuePair(HeaderNames.Referer, _collection._headers._Referer); + _next = 36; + return true; + } + HeaderRange: // case 36 + if ((_bits & 0x1000000000L) != 0) + { + _current = new KeyValuePair(HeaderNames.Range, _collection._headers._Range); + _next = 37; + return true; + } + HeaderTE: // case 37 + if ((_bits & 0x2000000000L) != 0) + { + _current = new KeyValuePair(HeaderNames.TE, _collection._headers._TE); + _next = 38; + return true; + } + HeaderTranslate: // case 38 + if ((_bits & 0x4000000000L) != 0) + { + _current = new KeyValuePair(HeaderNames.Translate, _collection._headers._Translate); + _next = 39; + return true; + } + HeaderUserAgent: // case 39 + if ((_bits & 0x8000000000L) != 0) + { + _current = new KeyValuePair(HeaderNames.UserAgent, _collection._headers._UserAgent); + _next = 40; + return true; + } + HeaderDNT: // case 40 + if ((_bits & 0x10000000000L) != 0) + { + _current = new KeyValuePair(HeaderNames.DNT, _collection._headers._DNT); + _next = 41; + return true; + } + HeaderUpgradeInsecureRequests: // case 41 + if ((_bits & 0x20000000000L) != 0) + { + _current = new KeyValuePair(HeaderNames.UpgradeInsecureRequests, _collection._headers._UpgradeInsecureRequests); + _next = 42; + return true; + } + HeaderRequestId: // case 42 + if ((_bits & 0x40000000000L) != 0) + { + _current = new KeyValuePair(HeaderNames.RequestId, _collection._headers._RequestId); + _next = 43; + return true; + } + HeaderCorrelationContext: // case 43 + if ((_bits & 0x80000000000L) != 0) + { + _current = new KeyValuePair(HeaderNames.CorrelationContext, _collection._headers._CorrelationContext); + _next = 44; + return true; + } + HeaderTraceParent: // case 44 + if ((_bits & 0x100000000000L) != 0) + { + _current = new KeyValuePair(HeaderNames.TraceParent, _collection._headers._TraceParent); + _next = 45; + return true; + } + HeaderTraceState: // case 45 + if ((_bits & 0x200000000000L) != 0) + { + _current = new KeyValuePair(HeaderNames.TraceState, _collection._headers._TraceState); + _next = 46; + return true; + } + HeaderOrigin: // case 46 + if ((_bits & 0x400000000000L) != 0) + { + _current = new KeyValuePair(HeaderNames.Origin, _collection._headers._Origin); + _next = 47; + return true; + } + HeaderAccessControlRequestMethod: // case 47 + if ((_bits & 0x800000000000L) != 0) + { + _current = new KeyValuePair(HeaderNames.AccessControlRequestMethod, _collection._headers._AccessControlRequestMethod); + _next = 48; + return true; + } + HeaderAccessControlRequestHeaders: // case 48 + if ((_bits & 0x1000000000000L) != 0) + { + _current = new KeyValuePair(HeaderNames.AccessControlRequestHeaders, _collection._headers._AccessControlRequestHeaders); + _next = 49; + return true; + } + HeaderContentLength: // case 49 + if (_collection._contentLength.HasValue) + { + _current = new KeyValuePair(HeaderNames.ContentLength, HeaderUtilities.FormatNonNegativeInt64(_collection._contentLength.Value)); + _next = 50; + return true; + } + ExtraHeaders: + if (!_hasUnknown || !_unknownEnumerator.MoveNext()) + { + _current = default(KeyValuePair); + return false; + } + _current = _unknownEnumerator.Current; + return true; + } + } + } + + internal partial class HttpResponseHeaders + { + private static ReadOnlySpan HeaderBytes => new byte[] + { + 13,10,67,97,99,104,101,45,67,111,110,116,114,111,108,58,32,13,10,67,111,110,110,101,99,116,105,111,110,58,32,13,10,68,97,116,101,58,32,13,10,75,101,101,112,45,65,108,105,118,101,58,32,13,10,80,114,97,103,109,97,58,32,13,10,84,114,97,105,108,101,114,58,32,13,10,84,114,97,110,115,102,101,114,45,69,110,99,111,100,105,110,103,58,32,13,10,85,112,103,114,97,100,101,58,32,13,10,86,105,97,58,32,13,10,87,97,114,110,105,110,103,58,32,13,10,65,108,108,111,119,58,32,13,10,67,111,110,116,101,110,116,45,84,121,112,101,58,32,13,10,67,111,110,116,101,110,116,45,69,110,99,111,100,105,110,103,58,32,13,10,67,111,110,116,101,110,116,45,76,97,110,103,117,97,103,101,58,32,13,10,67,111,110,116,101,110,116,45,76,111,99,97,116,105,111,110,58,32,13,10,67,111,110,116,101,110,116,45,77,68,53,58,32,13,10,67,111,110,116,101,110,116,45,82,97,110,103,101,58,32,13,10,69,120,112,105,114,101,115,58,32,13,10,76,97,115,116,45,77,111,100,105,102,105,101,100,58,32,13,10,65,99,99,101,112,116,45,82,97,110,103,101,115,58,32,13,10,65,103,101,58,32,13,10,69,84,97,103,58,32,13,10,76,111,99,97,116,105,111,110,58,32,13,10,80,114,111,120,121,45,65,117,116,104,101,110,116,105,99,97,116,101,58,32,13,10,82,101,116,114,121,45,65,102,116,101,114,58,32,13,10,83,101,114,118,101,114,58,32,13,10,83,101,116,45,67,111,111,107,105,101,58,32,13,10,86,97,114,121,58,32,13,10,87,87,87,45,65,117,116,104,101,110,116,105,99,97,116,101,58,32,13,10,65,99,99,101,115,115,45,67,111,110,116,114,111,108,45,65,108,108,111,119,45,67,114,101,100,101,110,116,105,97,108,115,58,32,13,10,65,99,99,101,115,115,45,67,111,110,116,114,111,108,45,65,108,108,111,119,45,72,101,97,100,101,114,115,58,32,13,10,65,99,99,101,115,115,45,67,111,110,116,114,111,108,45,65,108,108,111,119,45,77,101,116,104,111,100,115,58,32,13,10,65,99,99,101,115,115,45,67,111,110,116,114,111,108,45,65,108,108,111,119,45,79,114,105,103,105,110,58,32,13,10,65,99,99,101,115,115,45,67,111,110,116,114,111,108,45,69,120,112,111,115,101,45,72,101,97,100,101,114,115,58,32,13,10,65,99,99,101,115,115,45,67,111,110,116,114,111,108,45,77,97,120,45,65,103,101,58,32,13,10,67,111,110,116,101,110,116,45,76,101,110,103,116,104,58,32, + }; + private HeaderReferences _headers; + + public bool HasConnection => (_bits & 0x2L) != 0; + public bool HasDate => (_bits & 0x4L) != 0; + public bool HasTransferEncoding => (_bits & 0x40L) != 0; + public bool HasServer => (_bits & 0x2000000L) != 0; + + + public StringValues HeaderCacheControl + { + get + { + StringValues value = default; + if ((_bits & 0x1L) != 0) + { + value = _headers._CacheControl; + } + return value; + } + set + { + _bits |= 0x1L; + _headers._CacheControl = value; + } + } + public StringValues HeaderConnection + { + get + { + StringValues value = default; + if ((_bits & 0x2L) != 0) + { + value = _headers._Connection; + } + return value; + } + set + { + _bits |= 0x2L; + _headers._Connection = value; + _headers._rawConnection = null; + } + } + public StringValues HeaderDate + { + get + { + StringValues value = default; + if ((_bits & 0x4L) != 0) + { + value = _headers._Date; + } + return value; + } + set + { + _bits |= 0x4L; + _headers._Date = value; + _headers._rawDate = null; + } + } + public StringValues HeaderKeepAlive + { + get + { + StringValues value = default; + if ((_bits & 0x8L) != 0) + { + value = _headers._KeepAlive; + } + return value; + } + set + { + _bits |= 0x8L; + _headers._KeepAlive = value; + } + } + public StringValues HeaderPragma + { + get + { + StringValues value = default; + if ((_bits & 0x10L) != 0) + { + value = _headers._Pragma; + } + return value; + } + set + { + _bits |= 0x10L; + _headers._Pragma = value; + } + } + public StringValues HeaderTrailer + { + get + { + StringValues value = default; + if ((_bits & 0x20L) != 0) + { + value = _headers._Trailer; + } + return value; + } + set + { + _bits |= 0x20L; + _headers._Trailer = value; + } + } + public StringValues HeaderTransferEncoding + { + get + { + StringValues value = default; + if ((_bits & 0x40L) != 0) + { + value = _headers._TransferEncoding; + } + return value; + } + set + { + _bits |= 0x40L; + _headers._TransferEncoding = value; + _headers._rawTransferEncoding = null; + } + } + public StringValues HeaderUpgrade + { + get + { + StringValues value = default; + if ((_bits & 0x80L) != 0) + { + value = _headers._Upgrade; + } + return value; + } + set + { + _bits |= 0x80L; + _headers._Upgrade = value; + } + } + public StringValues HeaderVia + { + get + { + StringValues value = default; + if ((_bits & 0x100L) != 0) + { + value = _headers._Via; + } + return value; + } + set + { + _bits |= 0x100L; + _headers._Via = value; + } + } + public StringValues HeaderWarning + { + get + { + StringValues value = default; + if ((_bits & 0x200L) != 0) + { + value = _headers._Warning; + } + return value; + } + set + { + _bits |= 0x200L; + _headers._Warning = value; + } + } + public StringValues HeaderAllow + { + get + { + StringValues value = default; + if ((_bits & 0x400L) != 0) + { + value = _headers._Allow; + } + return value; + } + set + { + _bits |= 0x400L; + _headers._Allow = value; + } + } + public StringValues HeaderContentType + { + get + { + StringValues value = default; + if ((_bits & 0x800L) != 0) + { + value = _headers._ContentType; + } + return value; + } + set + { + _bits |= 0x800L; + _headers._ContentType = value; + } + } + public StringValues HeaderContentEncoding + { + get + { + StringValues value = default; + if ((_bits & 0x1000L) != 0) + { + value = _headers._ContentEncoding; + } + return value; + } + set + { + _bits |= 0x1000L; + _headers._ContentEncoding = value; + } + } + public StringValues HeaderContentLanguage + { + get + { + StringValues value = default; + if ((_bits & 0x2000L) != 0) + { + value = _headers._ContentLanguage; + } + return value; + } + set + { + _bits |= 0x2000L; + _headers._ContentLanguage = value; + } + } + public StringValues HeaderContentLocation + { + get + { + StringValues value = default; + if ((_bits & 0x4000L) != 0) + { + value = _headers._ContentLocation; + } + return value; + } + set + { + _bits |= 0x4000L; + _headers._ContentLocation = value; + } + } + public StringValues HeaderContentMD5 + { + get + { + StringValues value = default; + if ((_bits & 0x8000L) != 0) + { + value = _headers._ContentMD5; + } + return value; + } + set + { + _bits |= 0x8000L; + _headers._ContentMD5 = value; + } + } + public StringValues HeaderContentRange + { + get + { + StringValues value = default; + if ((_bits & 0x10000L) != 0) + { + value = _headers._ContentRange; + } + return value; + } + set + { + _bits |= 0x10000L; + _headers._ContentRange = value; + } + } + public StringValues HeaderExpires + { + get + { + StringValues value = default; + if ((_bits & 0x20000L) != 0) + { + value = _headers._Expires; + } + return value; + } + set + { + _bits |= 0x20000L; + _headers._Expires = value; } } - } - - internal partial class HttpResponseHeaders - { - private static ReadOnlySpan HeaderBytes => new byte[] + public StringValues HeaderLastModified { - 13,10,67,97,99,104,101,45,67,111,110,116,114,111,108,58,32,13,10,67,111,110,110,101,99,116,105,111,110,58,32,13,10,68,97,116,101,58,32,13,10,75,101,101,112,45,65,108,105,118,101,58,32,13,10,80,114,97,103,109,97,58,32,13,10,84,114,97,105,108,101,114,58,32,13,10,84,114,97,110,115,102,101,114,45,69,110,99,111,100,105,110,103,58,32,13,10,85,112,103,114,97,100,101,58,32,13,10,86,105,97,58,32,13,10,87,97,114,110,105,110,103,58,32,13,10,65,108,108,111,119,58,32,13,10,67,111,110,116,101,110,116,45,84,121,112,101,58,32,13,10,67,111,110,116,101,110,116,45,69,110,99,111,100,105,110,103,58,32,13,10,67,111,110,116,101,110,116,45,76,97,110,103,117,97,103,101,58,32,13,10,67,111,110,116,101,110,116,45,76,111,99,97,116,105,111,110,58,32,13,10,67,111,110,116,101,110,116,45,77,68,53,58,32,13,10,67,111,110,116,101,110,116,45,82,97,110,103,101,58,32,13,10,69,120,112,105,114,101,115,58,32,13,10,76,97,115,116,45,77,111,100,105,102,105,101,100,58,32,13,10,65,99,99,101,112,116,45,82,97,110,103,101,115,58,32,13,10,65,103,101,58,32,13,10,69,84,97,103,58,32,13,10,76,111,99,97,116,105,111,110,58,32,13,10,80,114,111,120,121,45,65,117,116,104,101,110,116,105,99,97,116,101,58,32,13,10,82,101,116,114,121,45,65,102,116,101,114,58,32,13,10,83,101,114,118,101,114,58,32,13,10,83,101,116,45,67,111,111,107,105,101,58,32,13,10,86,97,114,121,58,32,13,10,87,87,87,45,65,117,116,104,101,110,116,105,99,97,116,101,58,32,13,10,65,99,99,101,115,115,45,67,111,110,116,114,111,108,45,65,108,108,111,119,45,67,114,101,100,101,110,116,105,97,108,115,58,32,13,10,65,99,99,101,115,115,45,67,111,110,116,114,111,108,45,65,108,108,111,119,45,72,101,97,100,101,114,115,58,32,13,10,65,99,99,101,115,115,45,67,111,110,116,114,111,108,45,65,108,108,111,119,45,77,101,116,104,111,100,115,58,32,13,10,65,99,99,101,115,115,45,67,111,110,116,114,111,108,45,65,108,108,111,119,45,79,114,105,103,105,110,58,32,13,10,65,99,99,101,115,115,45,67,111,110,116,114,111,108,45,69,120,112,111,115,101,45,72,101,97,100,101,114,115,58,32,13,10,65,99,99,101,115,115,45,67,111,110,116,114,111,108,45,77,97,120,45,65,103,101,58,32,13,10,67,111,110,116,101,110,116,45,76,101,110,103,116,104,58,32, - }; - private HeaderReferences _headers; - - public bool HasConnection => (_bits & 0x2L) != 0; - public bool HasDate => (_bits & 0x4L) != 0; - public bool HasTransferEncoding => (_bits & 0x40L) != 0; - public bool HasServer => (_bits & 0x2000000L) != 0; - - - public StringValues HeaderCacheControl + get + { + StringValues value = default; + if ((_bits & 0x40000L) != 0) + { + value = _headers._LastModified; + } + return value; + } + set + { + _bits |= 0x40000L; + _headers._LastModified = value; + } + } + public StringValues HeaderAcceptRanges { get { StringValues value = default; - if ((_bits & 0x1L) != 0) + if ((_bits & 0x80000L) != 0) { - value = _headers._CacheControl; + value = _headers._AcceptRanges; } return value; } set { - _bits |= 0x1L; - _headers._CacheControl = value; + _bits |= 0x80000L; + _headers._AcceptRanges = value; } } - public StringValues HeaderConnection + public StringValues HeaderAge { get { StringValues value = default; - if ((_bits & 0x2L) != 0) + if ((_bits & 0x100000L) != 0) { - value = _headers._Connection; + value = _headers._Age; } return value; } set { - _bits |= 0x2L; - _headers._Connection = value; - _headers._rawConnection = null; + _bits |= 0x100000L; + _headers._Age = value; } } - public StringValues HeaderDate + public StringValues HeaderETag { get { StringValues value = default; - if ((_bits & 0x4L) != 0) + if ((_bits & 0x200000L) != 0) { - value = _headers._Date; + value = _headers._ETag; } return value; } set { - _bits |= 0x4L; - _headers._Date = value; - _headers._rawDate = null; + _bits |= 0x200000L; + _headers._ETag = value; } } - public StringValues HeaderKeepAlive + public StringValues HeaderLocation { get { StringValues value = default; - if ((_bits & 0x8L) != 0) + if ((_bits & 0x400000L) != 0) { - value = _headers._KeepAlive; + value = _headers._Location; + } + return value; + } + set + { + _bits |= 0x400000L; + _headers._Location = value; + } + } + public StringValues HeaderProxyAuthenticate + { + get + { + StringValues value = default; + if ((_bits & 0x800000L) != 0) + { + value = _headers._ProxyAuthenticate; + } + return value; + } + set + { + _bits |= 0x800000L; + _headers._ProxyAuthenticate = value; + } + } + public StringValues HeaderRetryAfter + { + get + { + StringValues value = default; + if ((_bits & 0x1000000L) != 0) + { + value = _headers._RetryAfter; + } + return value; + } + set + { + _bits |= 0x1000000L; + _headers._RetryAfter = value; + } + } + public StringValues HeaderServer + { + get + { + StringValues value = default; + if ((_bits & 0x2000000L) != 0) + { + value = _headers._Server; + } + return value; + } + set + { + _bits |= 0x2000000L; + _headers._Server = value; + _headers._rawServer = null; + } + } + public StringValues HeaderSetCookie + { + get + { + StringValues value = default; + if ((_bits & 0x4000000L) != 0) + { + value = _headers._SetCookie; + } + return value; + } + set + { + _bits |= 0x4000000L; + _headers._SetCookie = value; + } + } + public StringValues HeaderVary + { + get + { + StringValues value = default; + if ((_bits & 0x8000000L) != 0) + { + value = _headers._Vary; + } + return value; + } + set + { + _bits |= 0x8000000L; + _headers._Vary = value; + } + } + public StringValues HeaderWWWAuthenticate + { + get + { + StringValues value = default; + if ((_bits & 0x10000000L) != 0) + { + value = _headers._WWWAuthenticate; + } + return value; + } + set + { + _bits |= 0x10000000L; + _headers._WWWAuthenticate = value; + } + } + public StringValues HeaderAccessControlAllowCredentials + { + get + { + StringValues value = default; + if ((_bits & 0x20000000L) != 0) + { + value = _headers._AccessControlAllowCredentials; + } + return value; + } + set + { + _bits |= 0x20000000L; + _headers._AccessControlAllowCredentials = value; + } + } + public StringValues HeaderAccessControlAllowHeaders + { + get + { + StringValues value = default; + if ((_bits & 0x40000000L) != 0) + { + value = _headers._AccessControlAllowHeaders; + } + return value; + } + set + { + _bits |= 0x40000000L; + _headers._AccessControlAllowHeaders = value; + } + } + public StringValues HeaderAccessControlAllowMethods + { + get + { + StringValues value = default; + if ((_bits & 0x80000000L) != 0) + { + value = _headers._AccessControlAllowMethods; + } + return value; + } + set + { + _bits |= 0x80000000L; + _headers._AccessControlAllowMethods = value; + } + } + public StringValues HeaderAccessControlAllowOrigin + { + get + { + StringValues value = default; + if ((_bits & 0x100000000L) != 0) + { + value = _headers._AccessControlAllowOrigin; } return value; } set { - _bits |= 0x8L; - _headers._KeepAlive = value; + _bits |= 0x100000000L; + _headers._AccessControlAllowOrigin = value; } } - public StringValues HeaderPragma + public StringValues HeaderAccessControlExposeHeaders { get { StringValues value = default; - if ((_bits & 0x10L) != 0) + if ((_bits & 0x200000000L) != 0) { - value = _headers._Pragma; + value = _headers._AccessControlExposeHeaders; } return value; } set { - _bits |= 0x10L; - _headers._Pragma = value; + _bits |= 0x200000000L; + _headers._AccessControlExposeHeaders = value; } } - public StringValues HeaderTrailer + public StringValues HeaderAccessControlMaxAge { get { StringValues value = default; - if ((_bits & 0x20L) != 0) + if ((_bits & 0x400000000L) != 0) { - value = _headers._Trailer; + value = _headers._AccessControlMaxAge; } return value; } set { - _bits |= 0x20L; - _headers._Trailer = value; + _bits |= 0x400000000L; + _headers._AccessControlMaxAge = value; } } - public StringValues HeaderTransferEncoding + public StringValues HeaderContentLength { get { StringValues value = default; - if ((_bits & 0x40L) != 0) + if (_contentLength.HasValue) { - value = _headers._TransferEncoding; + value = new StringValues(HeaderUtilities.FormatNonNegativeInt64(_contentLength.Value)); } return value; } set { - _bits |= 0x40L; - _headers._TransferEncoding = value; - _headers._rawTransferEncoding = null; + _contentLength = ParseContentLength(value); } } - public StringValues HeaderUpgrade + + public void SetRawConnection(StringValues value, byte[] raw) { - get + _bits |= 0x2L; + _headers._Connection = value; + _headers._rawConnection = raw; + } + public void SetRawDate(StringValues value, byte[] raw) + { + _bits |= 0x4L; + _headers._Date = value; + _headers._rawDate = raw; + } + public void SetRawTransferEncoding(StringValues value, byte[] raw) + { + _bits |= 0x40L; + _headers._TransferEncoding = value; + _headers._rawTransferEncoding = raw; + } + public void SetRawServer(StringValues value, byte[] raw) + { + _bits |= 0x2000000L; + _headers._Server = value; + _headers._rawServer = raw; + } + protected override int GetCountFast() + { + return (_contentLength.HasValue ? 1 : 0 ) + BitCount(_bits) + (MaybeUnknown?.Count ?? 0); + } + + protected override bool TryGetValueFast(string key, out StringValues value) + { + value = default; + switch (key.Length) { - StringValues value = default; - if ((_bits & 0x80L) != 0) + case 3: + { + if (ReferenceEquals(HeaderNames.Via, key)) + { + if ((_bits & 0x100L) != 0) + { + value = _headers._Via; + return true; + } + return false; + } + if (ReferenceEquals(HeaderNames.Age, key)) + { + if ((_bits & 0x100000L) != 0) + { + value = _headers._Age; + return true; + } + return false; + } + + if (HeaderNames.Via.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x100L) != 0) + { + value = _headers._Via; + return true; + } + return false; + } + if (HeaderNames.Age.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x100000L) != 0) + { + value = _headers._Age; + return true; + } + return false; + } + break; + } + case 4: + { + if (ReferenceEquals(HeaderNames.Date, key)) + { + if ((_bits & 0x4L) != 0) + { + value = _headers._Date; + return true; + } + return false; + } + if (ReferenceEquals(HeaderNames.ETag, key)) + { + if ((_bits & 0x200000L) != 0) + { + value = _headers._ETag; + return true; + } + return false; + } + if (ReferenceEquals(HeaderNames.Vary, key)) + { + if ((_bits & 0x8000000L) != 0) + { + value = _headers._Vary; + return true; + } + return false; + } + + if (HeaderNames.Date.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x4L) != 0) + { + value = _headers._Date; + return true; + } + return false; + } + if (HeaderNames.ETag.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x200000L) != 0) + { + value = _headers._ETag; + return true; + } + return false; + } + if (HeaderNames.Vary.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x8000000L) != 0) + { + value = _headers._Vary; + return true; + } + return false; + } + break; + } + case 5: + { + if (ReferenceEquals(HeaderNames.Allow, key)) + { + if ((_bits & 0x400L) != 0) + { + value = _headers._Allow; + return true; + } + return false; + } + + if (HeaderNames.Allow.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x400L) != 0) + { + value = _headers._Allow; + return true; + } + return false; + } + break; + } + case 6: + { + if (ReferenceEquals(HeaderNames.Server, key)) + { + if ((_bits & 0x2000000L) != 0) + { + value = _headers._Server; + return true; + } + return false; + } + if (ReferenceEquals(HeaderNames.Pragma, key)) + { + if ((_bits & 0x10L) != 0) + { + value = _headers._Pragma; + return true; + } + return false; + } + + if (HeaderNames.Server.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x2000000L) != 0) + { + value = _headers._Server; + return true; + } + return false; + } + if (HeaderNames.Pragma.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x10L) != 0) + { + value = _headers._Pragma; + return true; + } + return false; + } + break; + } + case 7: + { + if (ReferenceEquals(HeaderNames.Trailer, key)) + { + if ((_bits & 0x20L) != 0) + { + value = _headers._Trailer; + return true; + } + return false; + } + if (ReferenceEquals(HeaderNames.Upgrade, key)) + { + if ((_bits & 0x80L) != 0) + { + value = _headers._Upgrade; + return true; + } + return false; + } + if (ReferenceEquals(HeaderNames.Warning, key)) + { + if ((_bits & 0x200L) != 0) + { + value = _headers._Warning; + return true; + } + return false; + } + if (ReferenceEquals(HeaderNames.Expires, key)) + { + if ((_bits & 0x20000L) != 0) + { + value = _headers._Expires; + return true; + } + return false; + } + + if (HeaderNames.Trailer.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x20L) != 0) + { + value = _headers._Trailer; + return true; + } + return false; + } + if (HeaderNames.Upgrade.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x80L) != 0) + { + value = _headers._Upgrade; + return true; + } + return false; + } + if (HeaderNames.Warning.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x200L) != 0) + { + value = _headers._Warning; + return true; + } + return false; + } + if (HeaderNames.Expires.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x20000L) != 0) + { + value = _headers._Expires; + return true; + } + return false; + } + break; + } + case 8: + { + if (ReferenceEquals(HeaderNames.Location, key)) + { + if ((_bits & 0x400000L) != 0) + { + value = _headers._Location; + return true; + } + return false; + } + + if (HeaderNames.Location.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x400000L) != 0) + { + value = _headers._Location; + return true; + } + return false; + } + break; + } + case 10: + { + if (ReferenceEquals(HeaderNames.Connection, key)) + { + if ((_bits & 0x2L) != 0) + { + value = _headers._Connection; + return true; + } + return false; + } + if (ReferenceEquals(HeaderNames.KeepAlive, key)) + { + if ((_bits & 0x8L) != 0) + { + value = _headers._KeepAlive; + return true; + } + return false; + } + if (ReferenceEquals(HeaderNames.SetCookie, key)) + { + if ((_bits & 0x4000000L) != 0) + { + value = _headers._SetCookie; + return true; + } + return false; + } + + if (HeaderNames.Connection.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x2L) != 0) + { + value = _headers._Connection; + return true; + } + return false; + } + if (HeaderNames.KeepAlive.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x8L) != 0) + { + value = _headers._KeepAlive; + return true; + } + return false; + } + if (HeaderNames.SetCookie.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x4000000L) != 0) + { + value = _headers._SetCookie; + return true; + } + return false; + } + break; + } + case 11: { - value = _headers._Upgrade; + if (ReferenceEquals(HeaderNames.ContentMD5, key)) + { + if ((_bits & 0x8000L) != 0) + { + value = _headers._ContentMD5; + return true; + } + return false; + } + if (ReferenceEquals(HeaderNames.RetryAfter, key)) + { + if ((_bits & 0x1000000L) != 0) + { + value = _headers._RetryAfter; + return true; + } + return false; + } + + if (HeaderNames.ContentMD5.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x8000L) != 0) + { + value = _headers._ContentMD5; + return true; + } + return false; + } + if (HeaderNames.RetryAfter.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x1000000L) != 0) + { + value = _headers._RetryAfter; + return true; + } + return false; + } + break; } - return value; - } - set - { - _bits |= 0x80L; - _headers._Upgrade = value; - } - } - public StringValues HeaderVia - { - get - { - StringValues value = default; - if ((_bits & 0x100L) != 0) + case 12: { - value = _headers._Via; + if (ReferenceEquals(HeaderNames.ContentType, key)) + { + if ((_bits & 0x800L) != 0) + { + value = _headers._ContentType; + return true; + } + return false; + } + + if (HeaderNames.ContentType.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x800L) != 0) + { + value = _headers._ContentType; + return true; + } + return false; + } + break; } - return value; - } - set - { - _bits |= 0x100L; - _headers._Via = value; - } - } - public StringValues HeaderWarning - { - get - { - StringValues value = default; - if ((_bits & 0x200L) != 0) + case 13: { - value = _headers._Warning; + if (ReferenceEquals(HeaderNames.CacheControl, key)) + { + if ((_bits & 0x1L) != 0) + { + value = _headers._CacheControl; + return true; + } + return false; + } + if (ReferenceEquals(HeaderNames.ContentRange, key)) + { + if ((_bits & 0x10000L) != 0) + { + value = _headers._ContentRange; + return true; + } + return false; + } + if (ReferenceEquals(HeaderNames.LastModified, key)) + { + if ((_bits & 0x40000L) != 0) + { + value = _headers._LastModified; + return true; + } + return false; + } + if (ReferenceEquals(HeaderNames.AcceptRanges, key)) + { + if ((_bits & 0x80000L) != 0) + { + value = _headers._AcceptRanges; + return true; + } + return false; + } + + if (HeaderNames.CacheControl.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x1L) != 0) + { + value = _headers._CacheControl; + return true; + } + return false; + } + if (HeaderNames.ContentRange.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x10000L) != 0) + { + value = _headers._ContentRange; + return true; + } + return false; + } + if (HeaderNames.LastModified.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x40000L) != 0) + { + value = _headers._LastModified; + return true; + } + return false; + } + if (HeaderNames.AcceptRanges.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x80000L) != 0) + { + value = _headers._AcceptRanges; + return true; + } + return false; + } + break; } - return value; - } - set - { - _bits |= 0x200L; - _headers._Warning = value; - } - } - public StringValues HeaderAllow - { - get - { - StringValues value = default; - if ((_bits & 0x400L) != 0) + case 14: { - value = _headers._Allow; + if (ReferenceEquals(HeaderNames.ContentLength, key)) + { + if (_contentLength.HasValue) + { + value = HeaderUtilities.FormatNonNegativeInt64(_contentLength.Value); + return true; + } + return false; + } + + if (HeaderNames.ContentLength.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if (_contentLength.HasValue) + { + value = HeaderUtilities.FormatNonNegativeInt64(_contentLength.Value); + return true; + } + return false; + } + break; } - return value; - } - set - { - _bits |= 0x400L; - _headers._Allow = value; - } - } - public StringValues HeaderContentType - { - get - { - StringValues value = default; - if ((_bits & 0x800L) != 0) + case 16: { - value = _headers._ContentType; + if (ReferenceEquals(HeaderNames.ContentEncoding, key)) + { + if ((_bits & 0x1000L) != 0) + { + value = _headers._ContentEncoding; + return true; + } + return false; + } + if (ReferenceEquals(HeaderNames.ContentLanguage, key)) + { + if ((_bits & 0x2000L) != 0) + { + value = _headers._ContentLanguage; + return true; + } + return false; + } + if (ReferenceEquals(HeaderNames.ContentLocation, key)) + { + if ((_bits & 0x4000L) != 0) + { + value = _headers._ContentLocation; + return true; + } + return false; + } + if (ReferenceEquals(HeaderNames.WWWAuthenticate, key)) + { + if ((_bits & 0x10000000L) != 0) + { + value = _headers._WWWAuthenticate; + return true; + } + return false; + } + + if (HeaderNames.ContentEncoding.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x1000L) != 0) + { + value = _headers._ContentEncoding; + return true; + } + return false; + } + if (HeaderNames.ContentLanguage.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x2000L) != 0) + { + value = _headers._ContentLanguage; + return true; + } + return false; + } + if (HeaderNames.ContentLocation.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x4000L) != 0) + { + value = _headers._ContentLocation; + return true; + } + return false; + } + if (HeaderNames.WWWAuthenticate.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x10000000L) != 0) + { + value = _headers._WWWAuthenticate; + return true; + } + return false; + } + break; } - return value; - } - set - { - _bits |= 0x800L; - _headers._ContentType = value; - } - } - public StringValues HeaderContentEncoding - { - get - { - StringValues value = default; - if ((_bits & 0x1000L) != 0) + case 17: { - value = _headers._ContentEncoding; + if (ReferenceEquals(HeaderNames.TransferEncoding, key)) + { + if ((_bits & 0x40L) != 0) + { + value = _headers._TransferEncoding; + return true; + } + return false; + } + + if (HeaderNames.TransferEncoding.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x40L) != 0) + { + value = _headers._TransferEncoding; + return true; + } + return false; + } + break; } - return value; - } - set - { - _bits |= 0x1000L; - _headers._ContentEncoding = value; - } - } - public StringValues HeaderContentLanguage - { - get - { - StringValues value = default; - if ((_bits & 0x2000L) != 0) + case 18: + { + if (ReferenceEquals(HeaderNames.ProxyAuthenticate, key)) + { + if ((_bits & 0x800000L) != 0) + { + value = _headers._ProxyAuthenticate; + return true; + } + return false; + } + + if (HeaderNames.ProxyAuthenticate.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x800000L) != 0) + { + value = _headers._ProxyAuthenticate; + return true; + } + return false; + } + break; + } + case 22: { - value = _headers._ContentLanguage; + if (ReferenceEquals(HeaderNames.AccessControlMaxAge, key)) + { + if ((_bits & 0x400000000L) != 0) + { + value = _headers._AccessControlMaxAge; + return true; + } + return false; + } + + if (HeaderNames.AccessControlMaxAge.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x400000000L) != 0) + { + value = _headers._AccessControlMaxAge; + return true; + } + return false; + } + break; } - return value; - } - set - { - _bits |= 0x2000L; - _headers._ContentLanguage = value; - } - } - public StringValues HeaderContentLocation - { - get - { - StringValues value = default; - if ((_bits & 0x4000L) != 0) + case 27: { - value = _headers._ContentLocation; + if (ReferenceEquals(HeaderNames.AccessControlAllowOrigin, key)) + { + if ((_bits & 0x100000000L) != 0) + { + value = _headers._AccessControlAllowOrigin; + return true; + } + return false; + } + + if (HeaderNames.AccessControlAllowOrigin.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x100000000L) != 0) + { + value = _headers._AccessControlAllowOrigin; + return true; + } + return false; + } + break; } - return value; - } - set - { - _bits |= 0x4000L; - _headers._ContentLocation = value; - } - } - public StringValues HeaderContentMD5 - { - get - { - StringValues value = default; - if ((_bits & 0x8000L) != 0) + case 28: { - value = _headers._ContentMD5; + if (ReferenceEquals(HeaderNames.AccessControlAllowHeaders, key)) + { + if ((_bits & 0x40000000L) != 0) + { + value = _headers._AccessControlAllowHeaders; + return true; + } + return false; + } + if (ReferenceEquals(HeaderNames.AccessControlAllowMethods, key)) + { + if ((_bits & 0x80000000L) != 0) + { + value = _headers._AccessControlAllowMethods; + return true; + } + return false; + } + + if (HeaderNames.AccessControlAllowHeaders.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x40000000L) != 0) + { + value = _headers._AccessControlAllowHeaders; + return true; + } + return false; + } + if (HeaderNames.AccessControlAllowMethods.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x80000000L) != 0) + { + value = _headers._AccessControlAllowMethods; + return true; + } + return false; + } + break; } - return value; - } - set - { - _bits |= 0x8000L; - _headers._ContentMD5 = value; - } - } - public StringValues HeaderContentRange - { - get - { - StringValues value = default; - if ((_bits & 0x10000L) != 0) + case 29: { - value = _headers._ContentRange; + if (ReferenceEquals(HeaderNames.AccessControlExposeHeaders, key)) + { + if ((_bits & 0x200000000L) != 0) + { + value = _headers._AccessControlExposeHeaders; + return true; + } + return false; + } + + if (HeaderNames.AccessControlExposeHeaders.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x200000000L) != 0) + { + value = _headers._AccessControlExposeHeaders; + return true; + } + return false; + } + break; } - return value; - } - set - { - _bits |= 0x10000L; - _headers._ContentRange = value; - } - } - public StringValues HeaderExpires - { - get - { - StringValues value = default; - if ((_bits & 0x20000L) != 0) + case 32: { - value = _headers._Expires; + if (ReferenceEquals(HeaderNames.AccessControlAllowCredentials, key)) + { + if ((_bits & 0x20000000L) != 0) + { + value = _headers._AccessControlAllowCredentials; + return true; + } + return false; + } + + if (HeaderNames.AccessControlAllowCredentials.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x20000000L) != 0) + { + value = _headers._AccessControlAllowCredentials; + return true; + } + return false; + } + break; } - return value; - } - set - { - _bits |= 0x20000L; - _headers._Expires = value; } + + return TryGetUnknown(key, ref value); } - public StringValues HeaderLastModified + + protected override void SetValueFast(string key, StringValues value) { - get + ValidateHeaderValueCharacters(value); + switch (key.Length) { - StringValues value = default; - if ((_bits & 0x40000L) != 0) + case 3: { - value = _headers._LastModified; + if (ReferenceEquals(HeaderNames.Via, key)) + { + _bits |= 0x100L; + _headers._Via = value; + return; + } + if (ReferenceEquals(HeaderNames.Age, key)) + { + _bits |= 0x100000L; + _headers._Age = value; + return; + } + + if (HeaderNames.Via.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x100L; + _headers._Via = value; + return; + } + if (HeaderNames.Age.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x100000L; + _headers._Age = value; + return; + } + break; } - return value; - } - set - { - _bits |= 0x40000L; - _headers._LastModified = value; - } - } - public StringValues HeaderAcceptRanges - { - get - { - StringValues value = default; - if ((_bits & 0x80000L) != 0) + case 4: { - value = _headers._AcceptRanges; + if (ReferenceEquals(HeaderNames.Date, key)) + { + _bits |= 0x4L; + _headers._Date = value; + _headers._rawDate = null; + return; + } + if (ReferenceEquals(HeaderNames.ETag, key)) + { + _bits |= 0x200000L; + _headers._ETag = value; + return; + } + if (ReferenceEquals(HeaderNames.Vary, key)) + { + _bits |= 0x8000000L; + _headers._Vary = value; + return; + } + + if (HeaderNames.Date.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x4L; + _headers._Date = value; + _headers._rawDate = null; + return; + } + if (HeaderNames.ETag.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x200000L; + _headers._ETag = value; + return; + } + if (HeaderNames.Vary.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x8000000L; + _headers._Vary = value; + return; + } + break; } - return value; - } - set - { - _bits |= 0x80000L; - _headers._AcceptRanges = value; - } - } - public StringValues HeaderAge - { - get - { - StringValues value = default; - if ((_bits & 0x100000L) != 0) + case 5: { - value = _headers._Age; + if (ReferenceEquals(HeaderNames.Allow, key)) + { + _bits |= 0x400L; + _headers._Allow = value; + return; + } + + if (HeaderNames.Allow.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x400L; + _headers._Allow = value; + return; + } + break; } - return value; - } - set - { - _bits |= 0x100000L; - _headers._Age = value; - } - } - public StringValues HeaderETag - { - get - { - StringValues value = default; - if ((_bits & 0x200000L) != 0) + case 6: + { + if (ReferenceEquals(HeaderNames.Server, key)) + { + _bits |= 0x2000000L; + _headers._Server = value; + _headers._rawServer = null; + return; + } + if (ReferenceEquals(HeaderNames.Pragma, key)) + { + _bits |= 0x10L; + _headers._Pragma = value; + return; + } + + if (HeaderNames.Server.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x2000000L; + _headers._Server = value; + _headers._rawServer = null; + return; + } + if (HeaderNames.Pragma.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x10L; + _headers._Pragma = value; + return; + } + break; + } + case 7: { - value = _headers._ETag; + if (ReferenceEquals(HeaderNames.Trailer, key)) + { + _bits |= 0x20L; + _headers._Trailer = value; + return; + } + if (ReferenceEquals(HeaderNames.Upgrade, key)) + { + _bits |= 0x80L; + _headers._Upgrade = value; + return; + } + if (ReferenceEquals(HeaderNames.Warning, key)) + { + _bits |= 0x200L; + _headers._Warning = value; + return; + } + if (ReferenceEquals(HeaderNames.Expires, key)) + { + _bits |= 0x20000L; + _headers._Expires = value; + return; + } + + if (HeaderNames.Trailer.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x20L; + _headers._Trailer = value; + return; + } + if (HeaderNames.Upgrade.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x80L; + _headers._Upgrade = value; + return; + } + if (HeaderNames.Warning.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x200L; + _headers._Warning = value; + return; + } + if (HeaderNames.Expires.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x20000L; + _headers._Expires = value; + return; + } + break; } - return value; - } - set - { - _bits |= 0x200000L; - _headers._ETag = value; - } - } - public StringValues HeaderLocation - { - get - { - StringValues value = default; - if ((_bits & 0x400000L) != 0) + case 8: { - value = _headers._Location; + if (ReferenceEquals(HeaderNames.Location, key)) + { + _bits |= 0x400000L; + _headers._Location = value; + return; + } + + if (HeaderNames.Location.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x400000L; + _headers._Location = value; + return; + } + break; } - return value; - } - set - { - _bits |= 0x400000L; - _headers._Location = value; - } - } - public StringValues HeaderProxyAuthenticate - { - get - { - StringValues value = default; - if ((_bits & 0x800000L) != 0) + case 10: { - value = _headers._ProxyAuthenticate; + if (ReferenceEquals(HeaderNames.Connection, key)) + { + _bits |= 0x2L; + _headers._Connection = value; + _headers._rawConnection = null; + return; + } + if (ReferenceEquals(HeaderNames.KeepAlive, key)) + { + _bits |= 0x8L; + _headers._KeepAlive = value; + return; + } + if (ReferenceEquals(HeaderNames.SetCookie, key)) + { + _bits |= 0x4000000L; + _headers._SetCookie = value; + return; + } + + if (HeaderNames.Connection.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x2L; + _headers._Connection = value; + _headers._rawConnection = null; + return; + } + if (HeaderNames.KeepAlive.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x8L; + _headers._KeepAlive = value; + return; + } + if (HeaderNames.SetCookie.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x4000000L; + _headers._SetCookie = value; + return; + } + break; } - return value; - } - set - { - _bits |= 0x800000L; - _headers._ProxyAuthenticate = value; - } - } - public StringValues HeaderRetryAfter - { - get - { - StringValues value = default; - if ((_bits & 0x1000000L) != 0) + case 11: { - value = _headers._RetryAfter; + if (ReferenceEquals(HeaderNames.ContentMD5, key)) + { + _bits |= 0x8000L; + _headers._ContentMD5 = value; + return; + } + if (ReferenceEquals(HeaderNames.RetryAfter, key)) + { + _bits |= 0x1000000L; + _headers._RetryAfter = value; + return; + } + + if (HeaderNames.ContentMD5.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x8000L; + _headers._ContentMD5 = value; + return; + } + if (HeaderNames.RetryAfter.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x1000000L; + _headers._RetryAfter = value; + return; + } + break; } - return value; - } - set - { - _bits |= 0x1000000L; - _headers._RetryAfter = value; - } - } - public StringValues HeaderServer - { - get - { - StringValues value = default; - if ((_bits & 0x2000000L) != 0) + case 12: { - value = _headers._Server; + if (ReferenceEquals(HeaderNames.ContentType, key)) + { + _bits |= 0x800L; + _headers._ContentType = value; + return; + } + + if (HeaderNames.ContentType.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x800L; + _headers._ContentType = value; + return; + } + break; } - return value; - } - set - { - _bits |= 0x2000000L; - _headers._Server = value; - _headers._rawServer = null; - } - } - public StringValues HeaderSetCookie - { - get - { - StringValues value = default; - if ((_bits & 0x4000000L) != 0) + case 13: { - value = _headers._SetCookie; + if (ReferenceEquals(HeaderNames.CacheControl, key)) + { + _bits |= 0x1L; + _headers._CacheControl = value; + return; + } + if (ReferenceEquals(HeaderNames.ContentRange, key)) + { + _bits |= 0x10000L; + _headers._ContentRange = value; + return; + } + if (ReferenceEquals(HeaderNames.LastModified, key)) + { + _bits |= 0x40000L; + _headers._LastModified = value; + return; + } + if (ReferenceEquals(HeaderNames.AcceptRanges, key)) + { + _bits |= 0x80000L; + _headers._AcceptRanges = value; + return; + } + + if (HeaderNames.CacheControl.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x1L; + _headers._CacheControl = value; + return; + } + if (HeaderNames.ContentRange.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x10000L; + _headers._ContentRange = value; + return; + } + if (HeaderNames.LastModified.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x40000L; + _headers._LastModified = value; + return; + } + if (HeaderNames.AcceptRanges.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x80000L; + _headers._AcceptRanges = value; + return; + } + break; } - return value; - } - set - { - _bits |= 0x4000000L; - _headers._SetCookie = value; - } - } - public StringValues HeaderVary - { - get - { - StringValues value = default; - if ((_bits & 0x8000000L) != 0) + case 14: { - value = _headers._Vary; + if (ReferenceEquals(HeaderNames.ContentLength, key)) + { + _contentLength = ParseContentLength(value.ToString()); + return; + } + + if (HeaderNames.ContentLength.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _contentLength = ParseContentLength(value.ToString()); + return; + } + break; } - return value; - } - set - { - _bits |= 0x8000000L; - _headers._Vary = value; - } - } - public StringValues HeaderWWWAuthenticate - { - get - { - StringValues value = default; - if ((_bits & 0x10000000L) != 0) + case 16: { - value = _headers._WWWAuthenticate; + if (ReferenceEquals(HeaderNames.ContentEncoding, key)) + { + _bits |= 0x1000L; + _headers._ContentEncoding = value; + return; + } + if (ReferenceEquals(HeaderNames.ContentLanguage, key)) + { + _bits |= 0x2000L; + _headers._ContentLanguage = value; + return; + } + if (ReferenceEquals(HeaderNames.ContentLocation, key)) + { + _bits |= 0x4000L; + _headers._ContentLocation = value; + return; + } + if (ReferenceEquals(HeaderNames.WWWAuthenticate, key)) + { + _bits |= 0x10000000L; + _headers._WWWAuthenticate = value; + return; + } + + if (HeaderNames.ContentEncoding.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x1000L; + _headers._ContentEncoding = value; + return; + } + if (HeaderNames.ContentLanguage.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x2000L; + _headers._ContentLanguage = value; + return; + } + if (HeaderNames.ContentLocation.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x4000L; + _headers._ContentLocation = value; + return; + } + if (HeaderNames.WWWAuthenticate.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x10000000L; + _headers._WWWAuthenticate = value; + return; + } + break; } - return value; - } - set - { - _bits |= 0x10000000L; - _headers._WWWAuthenticate = value; - } - } - public StringValues HeaderAccessControlAllowCredentials - { - get - { - StringValues value = default; - if ((_bits & 0x20000000L) != 0) + case 17: { - value = _headers._AccessControlAllowCredentials; + if (ReferenceEquals(HeaderNames.TransferEncoding, key)) + { + _bits |= 0x40L; + _headers._TransferEncoding = value; + _headers._rawTransferEncoding = null; + return; + } + + if (HeaderNames.TransferEncoding.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x40L; + _headers._TransferEncoding = value; + _headers._rawTransferEncoding = null; + return; + } + break; } - return value; - } - set - { - _bits |= 0x20000000L; - _headers._AccessControlAllowCredentials = value; - } - } - public StringValues HeaderAccessControlAllowHeaders - { - get - { - StringValues value = default; - if ((_bits & 0x40000000L) != 0) + case 18: { - value = _headers._AccessControlAllowHeaders; + if (ReferenceEquals(HeaderNames.ProxyAuthenticate, key)) + { + _bits |= 0x800000L; + _headers._ProxyAuthenticate = value; + return; + } + + if (HeaderNames.ProxyAuthenticate.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x800000L; + _headers._ProxyAuthenticate = value; + return; + } + break; } - return value; - } - set - { - _bits |= 0x40000000L; - _headers._AccessControlAllowHeaders = value; - } - } - public StringValues HeaderAccessControlAllowMethods - { - get - { - StringValues value = default; - if ((_bits & 0x80000000L) != 0) + case 22: { - value = _headers._AccessControlAllowMethods; + if (ReferenceEquals(HeaderNames.AccessControlMaxAge, key)) + { + _bits |= 0x400000000L; + _headers._AccessControlMaxAge = value; + return; + } + + if (HeaderNames.AccessControlMaxAge.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x400000000L; + _headers._AccessControlMaxAge = value; + return; + } + break; } - return value; - } - set - { - _bits |= 0x80000000L; - _headers._AccessControlAllowMethods = value; - } - } - public StringValues HeaderAccessControlAllowOrigin - { - get - { - StringValues value = default; - if ((_bits & 0x100000000L) != 0) + case 27: { - value = _headers._AccessControlAllowOrigin; + if (ReferenceEquals(HeaderNames.AccessControlAllowOrigin, key)) + { + _bits |= 0x100000000L; + _headers._AccessControlAllowOrigin = value; + return; + } + + if (HeaderNames.AccessControlAllowOrigin.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x100000000L; + _headers._AccessControlAllowOrigin = value; + return; + } + break; } - return value; - } - set - { - _bits |= 0x100000000L; - _headers._AccessControlAllowOrigin = value; - } - } - public StringValues HeaderAccessControlExposeHeaders - { - get - { - StringValues value = default; - if ((_bits & 0x200000000L) != 0) + case 28: { - value = _headers._AccessControlExposeHeaders; + if (ReferenceEquals(HeaderNames.AccessControlAllowHeaders, key)) + { + _bits |= 0x40000000L; + _headers._AccessControlAllowHeaders = value; + return; + } + if (ReferenceEquals(HeaderNames.AccessControlAllowMethods, key)) + { + _bits |= 0x80000000L; + _headers._AccessControlAllowMethods = value; + return; + } + + if (HeaderNames.AccessControlAllowHeaders.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x40000000L; + _headers._AccessControlAllowHeaders = value; + return; + } + if (HeaderNames.AccessControlAllowMethods.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x80000000L; + _headers._AccessControlAllowMethods = value; + return; + } + break; } - return value; - } - set - { - _bits |= 0x200000000L; - _headers._AccessControlExposeHeaders = value; - } - } - public StringValues HeaderAccessControlMaxAge - { - get - { - StringValues value = default; - if ((_bits & 0x400000000L) != 0) + case 29: { - value = _headers._AccessControlMaxAge; + if (ReferenceEquals(HeaderNames.AccessControlExposeHeaders, key)) + { + _bits |= 0x200000000L; + _headers._AccessControlExposeHeaders = value; + return; + } + + if (HeaderNames.AccessControlExposeHeaders.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x200000000L; + _headers._AccessControlExposeHeaders = value; + return; + } + break; } - return value; - } - set - { - _bits |= 0x400000000L; - _headers._AccessControlMaxAge = value; - } - } - public StringValues HeaderContentLength - { - get - { - StringValues value = default; - if (_contentLength.HasValue) + case 32: { - value = new StringValues(HeaderUtilities.FormatNonNegativeInt64(_contentLength.Value)); + if (ReferenceEquals(HeaderNames.AccessControlAllowCredentials, key)) + { + _bits |= 0x20000000L; + _headers._AccessControlAllowCredentials = value; + return; + } + + if (HeaderNames.AccessControlAllowCredentials.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x20000000L; + _headers._AccessControlAllowCredentials = value; + return; + } + break; } - return value; - } - set - { - _contentLength = ParseContentLength(value); } - } - public void SetRawConnection(StringValues value, byte[] raw) - { - _bits |= 0x2L; - _headers._Connection = value; - _headers._rawConnection = raw; - } - public void SetRawDate(StringValues value, byte[] raw) - { - _bits |= 0x4L; - _headers._Date = value; - _headers._rawDate = raw; - } - public void SetRawTransferEncoding(StringValues value, byte[] raw) - { - _bits |= 0x40L; - _headers._TransferEncoding = value; - _headers._rawTransferEncoding = raw; - } - public void SetRawServer(StringValues value, byte[] raw) - { - _bits |= 0x2000000L; - _headers._Server = value; - _headers._rawServer = raw; - } - protected override int GetCountFast() - { - return (_contentLength.HasValue ? 1 : 0 ) + BitCount(_bits) + (MaybeUnknown?.Count ?? 0); + SetValueUnknown(key, value); } - protected override bool TryGetValueFast(string key, out StringValues value) + protected override bool AddValueFast(string key, StringValues value) { - value = default; + ValidateHeaderValueCharacters(value); switch (key.Length) { - case 13: + case 3: + { + if (ReferenceEquals(HeaderNames.Via, key)) + { + if ((_bits & 0x100L) == 0) + { + _bits |= 0x100L; + _headers._Via = value; + return true; + } + return false; + } + if (ReferenceEquals(HeaderNames.Age, key)) + { + if ((_bits & 0x100000L) == 0) + { + _bits |= 0x100000L; + _headers._Age = value; + return true; + } + return false; + } + + if (HeaderNames.Via.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x100L) == 0) + { + _bits |= 0x100L; + _headers._Via = value; + return true; + } + return false; + } + if (HeaderNames.Age.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x100000L) == 0) + { + _bits |= 0x100000L; + _headers._Age = value; + return true; + } + return false; + } + break; + } + case 4: + { + if (ReferenceEquals(HeaderNames.Date, key)) + { + if ((_bits & 0x4L) == 0) + { + _bits |= 0x4L; + _headers._Date = value; + _headers._rawDate = null; + return true; + } + return false; + } + if (ReferenceEquals(HeaderNames.ETag, key)) { - if ("Cache-Control".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x200000L) == 0) { - if ((_bits & 0x1L) != 0) - { - value = _headers._CacheControl; - return true; - } - return false; + _bits |= 0x200000L; + _headers._ETag = value; + return true; } - if ("Content-Range".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (ReferenceEquals(HeaderNames.Vary, key)) + { + if ((_bits & 0x8000000L) == 0) { - if ((_bits & 0x10000L) != 0) - { - value = _headers._ContentRange; - return true; - } - return false; + _bits |= 0x8000000L; + _headers._Vary = value; + return true; } - if ("Last-Modified".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + + if (HeaderNames.Date.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x4L) == 0) { - if ((_bits & 0x40000L) != 0) - { - value = _headers._LastModified; - return true; - } - return false; + _bits |= 0x4L; + _headers._Date = value; + _headers._rawDate = null; + return true; } - if ("Accept-Ranges".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (HeaderNames.ETag.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x200000L) == 0) { - if ((_bits & 0x80000L) != 0) - { - value = _headers._AcceptRanges; - return true; - } - return false; + _bits |= 0x200000L; + _headers._ETag = value; + return true; } + return false; } - break; - case 10: + if (HeaderNames.Vary.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Connection".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x8000000L) == 0) { - if ((_bits & 0x2L) != 0) - { - value = _headers._Connection; - return true; - } - return false; + _bits |= 0x8000000L; + _headers._Vary = value; + return true; } - if ("Keep-Alive".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + break; + } + case 5: + { + if (ReferenceEquals(HeaderNames.Allow, key)) + { + if ((_bits & 0x400L) == 0) { - if ((_bits & 0x8L) != 0) - { - value = _headers._KeepAlive; - return true; - } - return false; + _bits |= 0x400L; + _headers._Allow = value; + return true; } - if ("Set-Cookie".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + + if (HeaderNames.Allow.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x400L) == 0) { - if ((_bits & 0x4000000L) != 0) - { - value = _headers._SetCookie; - return true; - } - return false; + _bits |= 0x400L; + _headers._Allow = value; + return true; } + return false; } break; - case 4: + } + case 6: + { + if (ReferenceEquals(HeaderNames.Server, key)) { - if ("Date".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x4L) != 0) - { - value = _headers._Date; - return true; - } - return false; - } - if ("ETag".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x2000000L) == 0) { - if ((_bits & 0x200000L) != 0) - { - value = _headers._ETag; - return true; - } - return false; + _bits |= 0x2000000L; + _headers._Server = value; + _headers._rawServer = null; + return true; } - if ("Vary".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (ReferenceEquals(HeaderNames.Pragma, key)) + { + if ((_bits & 0x10L) == 0) { - if ((_bits & 0x8000000L) != 0) - { - value = _headers._Vary; - return true; - } - return false; + _bits |= 0x10L; + _headers._Pragma = value; + return true; } + return false; } - break; - case 6: + + if (HeaderNames.Server.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Pragma".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x2000000L) == 0) { - if ((_bits & 0x10L) != 0) - { - value = _headers._Pragma; - return true; - } - return false; + _bits |= 0x2000000L; + _headers._Server = value; + _headers._rawServer = null; + return true; } - if ("Server".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (HeaderNames.Pragma.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x10L) == 0) { - if ((_bits & 0x2000000L) != 0) - { - value = _headers._Server; - return true; - } - return false; + _bits |= 0x10L; + _headers._Pragma = value; + return true; } + return false; } break; + } case 7: + { + if (ReferenceEquals(HeaderNames.Trailer, key)) { - if ("Trailer".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x20L) == 0) { - if ((_bits & 0x20L) != 0) - { - value = _headers._Trailer; - return true; - } - return false; + _bits |= 0x20L; + _headers._Trailer = value; + return true; } - if ("Upgrade".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (ReferenceEquals(HeaderNames.Upgrade, key)) + { + if ((_bits & 0x80L) == 0) { - if ((_bits & 0x80L) != 0) - { - value = _headers._Upgrade; - return true; - } - return false; + _bits |= 0x80L; + _headers._Upgrade = value; + return true; } - if ("Warning".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (ReferenceEquals(HeaderNames.Warning, key)) + { + if ((_bits & 0x200L) == 0) { - if ((_bits & 0x200L) != 0) - { - value = _headers._Warning; - return true; - } - return false; + _bits |= 0x200L; + _headers._Warning = value; + return true; } - if ("Expires".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (ReferenceEquals(HeaderNames.Expires, key)) + { + if ((_bits & 0x20000L) == 0) { - if ((_bits & 0x20000L) != 0) - { - value = _headers._Expires; - return true; - } - return false; + _bits |= 0x20000L; + _headers._Expires = value; + return true; } + return false; } - break; - case 17: + + if (HeaderNames.Trailer.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Transfer-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x20L) == 0) { - if ((_bits & 0x40L) != 0) - { - value = _headers._TransferEncoding; - return true; - } - return false; + _bits |= 0x20L; + _headers._Trailer = value; + return true; } + return false; } - break; - case 3: + if (HeaderNames.Upgrade.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Via".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x80L) == 0) { - if ((_bits & 0x100L) != 0) - { - value = _headers._Via; - return true; - } - return false; + _bits |= 0x80L; + _headers._Upgrade = value; + return true; } - if ("Age".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (HeaderNames.Warning.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x200L) == 0) { - if ((_bits & 0x100000L) != 0) - { - value = _headers._Age; - return true; - } - return false; + _bits |= 0x200L; + _headers._Warning = value; + return true; } + return false; } - break; - case 5: + if (HeaderNames.Expires.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Allow".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x20000L) == 0) { - if ((_bits & 0x400L) != 0) - { - value = _headers._Allow; - return true; - } - return false; + _bits |= 0x20000L; + _headers._Expires = value; + return true; } + return false; } break; - case 12: + } + case 8: + { + if (ReferenceEquals(HeaderNames.Location, key)) { - if ("Content-Type".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x400000L) == 0) { - if ((_bits & 0x800L) != 0) - { - value = _headers._ContentType; - return true; - } - return false; + _bits |= 0x400000L; + _headers._Location = value; + return true; + } + return false; + } + + if (HeaderNames.Location.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x400000L) == 0) + { + _bits |= 0x400000L; + _headers._Location = value; + return true; } + return false; } break; - case 16: + } + case 10: + { + if (ReferenceEquals(HeaderNames.Connection, key)) { - if ("Content-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x2L) == 0) { - if ((_bits & 0x1000L) != 0) - { - value = _headers._ContentEncoding; - return true; - } - return false; + _bits |= 0x2L; + _headers._Connection = value; + _headers._rawConnection = null; + return true; } - if ("Content-Language".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (ReferenceEquals(HeaderNames.KeepAlive, key)) + { + if ((_bits & 0x8L) == 0) { - if ((_bits & 0x2000L) != 0) - { - value = _headers._ContentLanguage; - return true; - } - return false; + _bits |= 0x8L; + _headers._KeepAlive = value; + return true; } - if ("Content-Location".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (ReferenceEquals(HeaderNames.SetCookie, key)) + { + if ((_bits & 0x4000000L) == 0) { - if ((_bits & 0x4000L) != 0) - { - value = _headers._ContentLocation; - return true; - } - return false; + _bits |= 0x4000000L; + _headers._SetCookie = value; + return true; } - if ("WWW-Authenticate".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + + if (HeaderNames.Connection.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x2L) == 0) { - if ((_bits & 0x10000000L) != 0) - { - value = _headers._WWWAuthenticate; - return true; - } - return false; + _bits |= 0x2L; + _headers._Connection = value; + _headers._rawConnection = null; + return true; } + return false; } - break; - case 11: + if (HeaderNames.KeepAlive.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Content-MD5".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x8L) == 0) { - if ((_bits & 0x8000L) != 0) - { - value = _headers._ContentMD5; - return true; - } - return false; + _bits |= 0x8L; + _headers._KeepAlive = value; + return true; } - if ("Retry-After".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (HeaderNames.SetCookie.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x4000000L) == 0) { - if ((_bits & 0x1000000L) != 0) - { - value = _headers._RetryAfter; - return true; - } - return false; + _bits |= 0x4000000L; + _headers._SetCookie = value; + return true; } + return false; } break; - case 8: + } + case 11: + { + if (ReferenceEquals(HeaderNames.ContentMD5, key)) { - if ("Location".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x8000L) == 0) { - if ((_bits & 0x400000L) != 0) - { - value = _headers._Location; - return true; - } - return false; + _bits |= 0x8000L; + _headers._ContentMD5 = value; + return true; } + return false; } - break; - case 18: + if (ReferenceEquals(HeaderNames.RetryAfter, key)) { - if ("Proxy-Authenticate".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x1000000L) == 0) { - if ((_bits & 0x800000L) != 0) - { - value = _headers._ProxyAuthenticate; - return true; - } - return false; + _bits |= 0x1000000L; + _headers._RetryAfter = value; + return true; } + return false; } - break; - case 32: + + if (HeaderNames.ContentMD5.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Access-Control-Allow-Credentials".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x8000L) == 0) { - if ((_bits & 0x20000000L) != 0) - { - value = _headers._AccessControlAllowCredentials; - return true; - } - return false; + _bits |= 0x8000L; + _headers._ContentMD5 = value; + return true; + } + return false; + } + if (HeaderNames.RetryAfter.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x1000000L) == 0) + { + _bits |= 0x1000000L; + _headers._RetryAfter = value; + return true; } + return false; } break; - case 28: + } + case 12: + { + if (ReferenceEquals(HeaderNames.ContentType, key)) { - if ("Access-Control-Allow-Headers".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x800L) == 0) { - if ((_bits & 0x40000000L) != 0) - { - value = _headers._AccessControlAllowHeaders; - return true; - } - return false; + _bits |= 0x800L; + _headers._ContentType = value; + return true; } - if ("Access-Control-Allow-Methods".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + + if (HeaderNames.ContentType.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x800L) == 0) { - if ((_bits & 0x80000000L) != 0) - { - value = _headers._AccessControlAllowMethods; - return true; - } - return false; + _bits |= 0x800L; + _headers._ContentType = value; + return true; } + return false; } break; - case 27: + } + case 13: + { + if (ReferenceEquals(HeaderNames.CacheControl, key)) { - if ("Access-Control-Allow-Origin".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x1L) == 0) { - if ((_bits & 0x100000000L) != 0) - { - value = _headers._AccessControlAllowOrigin; - return true; - } - return false; + _bits |= 0x1L; + _headers._CacheControl = value; + return true; } + return false; } - break; - case 29: + if (ReferenceEquals(HeaderNames.ContentRange, key)) { - if ("Access-Control-Expose-Headers".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x10000L) == 0) { - if ((_bits & 0x200000000L) != 0) - { - value = _headers._AccessControlExposeHeaders; - return true; - } - return false; + _bits |= 0x10000L; + _headers._ContentRange = value; + return true; } + return false; } - break; - case 22: + if (ReferenceEquals(HeaderNames.LastModified, key)) { - if ("Access-Control-Max-Age".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x40000L) == 0) { - if ((_bits & 0x400000000L) != 0) - { - value = _headers._AccessControlMaxAge; - return true; - } - return false; + _bits |= 0x40000L; + _headers._LastModified = value; + return true; } + return false; } - break; - case 14: + if (ReferenceEquals(HeaderNames.AcceptRanges, key)) { - if ("Content-Length".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x80000L) == 0) { - if (_contentLength.HasValue) - { - value = HeaderUtilities.FormatNonNegativeInt64(_contentLength.Value); - return true; - } - return false; + _bits |= 0x80000L; + _headers._AcceptRanges = value; + return true; } + return false; } - break; - } - - return MaybeUnknown?.TryGetValue(key, out value) ?? false; - } - - protected override void SetValueFast(string key, StringValues value) - { - ValidateHeaderValueCharacters(value); - switch (key.Length) - { - case 13: + + if (HeaderNames.CacheControl.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Cache-Control".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x1L) == 0) { _bits |= 0x1L; _headers._CacheControl = value; - return; + return true; } - if ("Content-Range".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (HeaderNames.ContentRange.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x10000L) == 0) { _bits |= 0x10000L; _headers._ContentRange = value; - return; + return true; } - if ("Last-Modified".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (HeaderNames.LastModified.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x40000L) == 0) { _bits |= 0x40000L; _headers._LastModified = value; - return; + return true; } - if ("Accept-Ranges".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (HeaderNames.AcceptRanges.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x80000L) == 0) { _bits |= 0x80000L; _headers._AcceptRanges = value; - return; + return true; } + return false; } break; - case 10: + } + case 14: + { + if (ReferenceEquals(HeaderNames.ContentLength, key)) { - if ("Connection".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - _bits |= 0x2L; - _headers._Connection = value; - _headers._rawConnection = null; - return; - } - if ("Keep-Alive".Equals(key, StringComparison.OrdinalIgnoreCase)) + if (!_contentLength.HasValue) { - _bits |= 0x8L; - _headers._KeepAlive = value; - return; + _contentLength = ParseContentLength(value); + return true; } - if ("Set-Cookie".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + + if (HeaderNames.ContentLength.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if (!_contentLength.HasValue) { - _bits |= 0x4000000L; - _headers._SetCookie = value; - return; + _contentLength = ParseContentLength(value); + return true; } + return false; } break; - case 4: + } + case 16: + { + if (ReferenceEquals(HeaderNames.ContentEncoding, key)) { - if ("Date".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - _bits |= 0x4L; - _headers._Date = value; - _headers._rawDate = null; - return; - } - if ("ETag".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x1000L) == 0) { - _bits |= 0x200000L; - _headers._ETag = value; - return; + _bits |= 0x1000L; + _headers._ContentEncoding = value; + return true; } - if ("Vary".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (ReferenceEquals(HeaderNames.ContentLanguage, key)) + { + if ((_bits & 0x2000L) == 0) { - _bits |= 0x8000000L; - _headers._Vary = value; - return; + _bits |= 0x2000L; + _headers._ContentLanguage = value; + return true; } + return false; } - break; - case 6: + if (ReferenceEquals(HeaderNames.ContentLocation, key)) { - if ("Pragma".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x4000L) == 0) { - _bits |= 0x10L; - _headers._Pragma = value; - return; + _bits |= 0x4000L; + _headers._ContentLocation = value; + return true; } - if ("Server".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (ReferenceEquals(HeaderNames.WWWAuthenticate, key)) + { + if ((_bits & 0x10000000L) == 0) { - _bits |= 0x2000000L; - _headers._Server = value; - _headers._rawServer = null; - return; + _bits |= 0x10000000L; + _headers._WWWAuthenticate = value; + return true; } + return false; } - break; - case 7: + + if (HeaderNames.ContentEncoding.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Trailer".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x1000L) == 0) { - _bits |= 0x20L; - _headers._Trailer = value; - return; + _bits |= 0x1000L; + _headers._ContentEncoding = value; + return true; } - if ("Upgrade".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (HeaderNames.ContentLanguage.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x2000L) == 0) { - _bits |= 0x80L; - _headers._Upgrade = value; - return; + _bits |= 0x2000L; + _headers._ContentLanguage = value; + return true; } - if ("Warning".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (HeaderNames.ContentLocation.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x4000L) == 0) { - _bits |= 0x200L; - _headers._Warning = value; - return; + _bits |= 0x4000L; + _headers._ContentLocation = value; + return true; } - if ("Expires".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (HeaderNames.WWWAuthenticate.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x10000000L) == 0) { - _bits |= 0x20000L; - _headers._Expires = value; - return; + _bits |= 0x10000000L; + _headers._WWWAuthenticate = value; + return true; } + return false; } break; + } case 17: + { + if (ReferenceEquals(HeaderNames.TransferEncoding, key)) { - if ("Transfer-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x40L) == 0) { _bits |= 0x40L; _headers._TransferEncoding = value; _headers._rawTransferEncoding = null; - return; + return true; } + return false; } - break; - case 3: + + if (HeaderNames.TransferEncoding.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Via".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - _bits |= 0x100L; - _headers._Via = value; - return; - } - if ("Age".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x40L) == 0) { - _bits |= 0x100000L; - _headers._Age = value; - return; + _bits |= 0x40L; + _headers._TransferEncoding = value; + _headers._rawTransferEncoding = null; + return true; } + return false; } break; - case 5: + } + case 18: + { + if (ReferenceEquals(HeaderNames.ProxyAuthenticate, key)) { - if ("Allow".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x800000L) == 0) { - _bits |= 0x400L; - _headers._Allow = value; - return; + _bits |= 0x800000L; + _headers._ProxyAuthenticate = value; + return true; } + return false; } - break; - case 12: + + if (HeaderNames.ProxyAuthenticate.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Content-Type".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x800000L) == 0) { - _bits |= 0x800L; - _headers._ContentType = value; - return; + _bits |= 0x800000L; + _headers._ProxyAuthenticate = value; + return true; } + return false; } break; - case 16: + } + case 22: + { + if (ReferenceEquals(HeaderNames.AccessControlMaxAge, key)) { - if ("Content-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - _bits |= 0x1000L; - _headers._ContentEncoding = value; - return; - } - if ("Content-Language".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x400000000L) == 0) { - _bits |= 0x2000L; - _headers._ContentLanguage = value; - return; - } - if ("Content-Location".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - _bits |= 0x4000L; - _headers._ContentLocation = value; - return; + _bits |= 0x400000000L; + _headers._AccessControlMaxAge = value; + return true; } - if ("WWW-Authenticate".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + + if (HeaderNames.AccessControlMaxAge.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x400000000L) == 0) { - _bits |= 0x10000000L; - _headers._WWWAuthenticate = value; - return; + _bits |= 0x400000000L; + _headers._AccessControlMaxAge = value; + return true; } + return false; } break; - case 11: + } + case 27: + { + if (ReferenceEquals(HeaderNames.AccessControlAllowOrigin, key)) { - if ("Content-MD5".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - _bits |= 0x8000L; - _headers._ContentMD5 = value; - return; - } - if ("Retry-After".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x100000000L) == 0) { - _bits |= 0x1000000L; - _headers._RetryAfter = value; - return; + _bits |= 0x100000000L; + _headers._AccessControlAllowOrigin = value; + return true; } + return false; } - break; - case 8: + + if (HeaderNames.AccessControlAllowOrigin.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Location".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x100000000L) == 0) { - _bits |= 0x400000L; - _headers._Location = value; - return; + _bits |= 0x100000000L; + _headers._AccessControlAllowOrigin = value; + return true; } + return false; } break; - case 18: + } + case 28: + { + if (ReferenceEquals(HeaderNames.AccessControlAllowHeaders, key)) { - if ("Proxy-Authenticate".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x40000000L) == 0) { - _bits |= 0x800000L; - _headers._ProxyAuthenticate = value; - return; + _bits |= 0x40000000L; + _headers._AccessControlAllowHeaders = value; + return true; } + return false; } - break; - case 32: + if (ReferenceEquals(HeaderNames.AccessControlAllowMethods, key)) { - if ("Access-Control-Allow-Credentials".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x80000000L) == 0) { - _bits |= 0x20000000L; - _headers._AccessControlAllowCredentials = value; - return; + _bits |= 0x80000000L; + _headers._AccessControlAllowMethods = value; + return true; } + return false; } - break; - case 28: + + if (HeaderNames.AccessControlAllowHeaders.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Access-Control-Allow-Headers".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x40000000L) == 0) { _bits |= 0x40000000L; _headers._AccessControlAllowHeaders = value; - return; + return true; } - if ("Access-Control-Allow-Methods".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (HeaderNames.AccessControlAllowMethods.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x80000000L) == 0) { _bits |= 0x80000000L; _headers._AccessControlAllowMethods = value; - return; + return true; } + return false; } break; - case 27: + } + case 29: + { + if (ReferenceEquals(HeaderNames.AccessControlExposeHeaders, key)) { - if ("Access-Control-Allow-Origin".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x200000000L) == 0) { - _bits |= 0x100000000L; - _headers._AccessControlAllowOrigin = value; - return; + _bits |= 0x200000000L; + _headers._AccessControlExposeHeaders = value; + return true; } + return false; } - break; - case 29: + + if (HeaderNames.AccessControlExposeHeaders.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Access-Control-Expose-Headers".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x200000000L) == 0) { _bits |= 0x200000000L; _headers._AccessControlExposeHeaders = value; - return; + return true; } + return false; } break; - case 22: + } + case 32: + { + if (ReferenceEquals(HeaderNames.AccessControlAllowCredentials, key)) { - if ("Access-Control-Max-Age".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x20000000L) == 0) { - _bits |= 0x400000000L; - _headers._AccessControlMaxAge = value; - return; + _bits |= 0x20000000L; + _headers._AccessControlAllowCredentials = value; + return true; } + return false; } - break; - case 14: + + if (HeaderNames.AccessControlAllowCredentials.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Content-Length".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x20000000L) == 0) { - _contentLength = ParseContentLength(value.ToString()); - return; + _bits |= 0x20000000L; + _headers._AccessControlAllowCredentials = value; + return true; } + return false; } break; + } } - SetValueUnknown(key, value); + return AddValueUnknown(key, value); } - protected override bool AddValueFast(string key, StringValues value) + protected override bool RemoveFast(string key) { - ValidateHeaderValueCharacters(value); switch (key.Length) { - case 13: + case 3: + { + if (ReferenceEquals(HeaderNames.Via, key)) { - if ("Cache-Control".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x100L) != 0) { - if ((_bits & 0x1L) == 0) - { - _bits |= 0x1L; - _headers._CacheControl = value; - return true; - } - return false; + _bits &= ~0x100L; + _headers._Via = default(StringValues); + return true; } - if ("Content-Range".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (ReferenceEquals(HeaderNames.Age, key)) + { + if ((_bits & 0x100000L) != 0) { - if ((_bits & 0x10000L) == 0) - { - _bits |= 0x10000L; - _headers._ContentRange = value; - return true; - } - return false; + _bits &= ~0x100000L; + _headers._Age = default(StringValues); + return true; } - if ("Last-Modified".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + + if (HeaderNames.Via.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x100L) != 0) { - if ((_bits & 0x40000L) == 0) - { - _bits |= 0x40000L; - _headers._LastModified = value; - return true; - } - return false; + _bits &= ~0x100L; + _headers._Via = default(StringValues); + return true; } - if ("Accept-Ranges".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (HeaderNames.Age.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x100000L) != 0) { - if ((_bits & 0x80000L) == 0) - { - _bits |= 0x80000L; - _headers._AcceptRanges = value; - return true; - } - return false; + _bits &= ~0x100000L; + _headers._Age = default(StringValues); + return true; } + return false; } break; - case 10: + } + case 4: + { + if (ReferenceEquals(HeaderNames.Date, key)) { - if ("Connection".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x4L) != 0) { - if ((_bits & 0x2L) == 0) - { - _bits |= 0x2L; - _headers._Connection = value; - _headers._rawConnection = null; - return true; - } - return false; + _bits &= ~0x4L; + _headers._Date = default(StringValues); + _headers._rawDate = null; + return true; } - if ("Keep-Alive".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (ReferenceEquals(HeaderNames.ETag, key)) + { + if ((_bits & 0x200000L) != 0) { - if ((_bits & 0x8L) == 0) - { - _bits |= 0x8L; - _headers._KeepAlive = value; - return true; - } - return false; + _bits &= ~0x200000L; + _headers._ETag = default(StringValues); + return true; } - if ("Set-Cookie".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (ReferenceEquals(HeaderNames.Vary, key)) + { + if ((_bits & 0x8000000L) != 0) { - if ((_bits & 0x4000000L) == 0) - { - _bits |= 0x4000000L; - _headers._SetCookie = value; - return true; - } - return false; + _bits &= ~0x8000000L; + _headers._Vary = default(StringValues); + return true; } + return false; } - break; - case 4: + + if (HeaderNames.Date.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Date".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x4L) != 0) { - if ((_bits & 0x4L) == 0) - { - _bits |= 0x4L; - _headers._Date = value; - _headers._rawDate = null; - return true; - } - return false; + _bits &= ~0x4L; + _headers._Date = default(StringValues); + _headers._rawDate = null; + return true; } - if ("ETag".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (HeaderNames.ETag.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x200000L) != 0) { - if ((_bits & 0x200000L) == 0) - { - _bits |= 0x200000L; - _headers._ETag = value; - return true; - } - return false; + _bits &= ~0x200000L; + _headers._ETag = default(StringValues); + return true; } - if ("Vary".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (HeaderNames.Vary.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x8000000L) != 0) { - if ((_bits & 0x8000000L) == 0) - { - _bits |= 0x8000000L; - _headers._Vary = value; - return true; - } - return false; + _bits &= ~0x8000000L; + _headers._Vary = default(StringValues); + return true; } + return false; } break; - case 6: + } + case 5: + { + if (ReferenceEquals(HeaderNames.Allow, key)) { - if ("Pragma".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x400L) != 0) { - if ((_bits & 0x10L) == 0) - { - _bits |= 0x10L; - _headers._Pragma = value; - return true; - } - return false; + _bits &= ~0x400L; + _headers._Allow = default(StringValues); + return true; } - if ("Server".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + + if (HeaderNames.Allow.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x400L) != 0) { - if ((_bits & 0x2000000L) == 0) - { - _bits |= 0x2000000L; - _headers._Server = value; - _headers._rawServer = null; - return true; - } - return false; + _bits &= ~0x400L; + _headers._Allow = default(StringValues); + return true; } + return false; } break; - case 7: + } + case 6: + { + if (ReferenceEquals(HeaderNames.Server, key)) { - if ("Trailer".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x20L) == 0) - { - _bits |= 0x20L; - _headers._Trailer = value; - return true; - } - return false; - } - if ("Upgrade".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x2000000L) != 0) { - if ((_bits & 0x80L) == 0) - { - _bits |= 0x80L; - _headers._Upgrade = value; - return true; - } - return false; + _bits &= ~0x2000000L; + _headers._Server = default(StringValues); + _headers._rawServer = null; + return true; } - if ("Warning".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (ReferenceEquals(HeaderNames.Pragma, key)) + { + if ((_bits & 0x10L) != 0) { - if ((_bits & 0x200L) == 0) - { - _bits |= 0x200L; - _headers._Warning = value; - return true; - } - return false; + _bits &= ~0x10L; + _headers._Pragma = default(StringValues); + return true; } - if ("Expires".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + + if (HeaderNames.Server.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x2000000L) != 0) { - if ((_bits & 0x20000L) == 0) - { - _bits |= 0x20000L; - _headers._Expires = value; - return true; - } - return false; + _bits &= ~0x2000000L; + _headers._Server = default(StringValues); + _headers._rawServer = null; + return true; } + return false; } - break; - case 17: + if (HeaderNames.Pragma.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Transfer-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x10L) != 0) { - if ((_bits & 0x40L) == 0) - { - _bits |= 0x40L; - _headers._TransferEncoding = value; - _headers._rawTransferEncoding = null; - return true; - } - return false; + _bits &= ~0x10L; + _headers._Pragma = default(StringValues); + return true; } + return false; } break; - case 3: + } + case 7: + { + if (ReferenceEquals(HeaderNames.Trailer, key)) { - if ("Via".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x20L) != 0) { - if ((_bits & 0x100L) == 0) - { - _bits |= 0x100L; - _headers._Via = value; - return true; - } - return false; + _bits &= ~0x20L; + _headers._Trailer = default(StringValues); + return true; } - if ("Age".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (ReferenceEquals(HeaderNames.Upgrade, key)) + { + if ((_bits & 0x80L) != 0) { - if ((_bits & 0x100000L) == 0) - { - _bits |= 0x100000L; - _headers._Age = value; - return true; - } - return false; + _bits &= ~0x80L; + _headers._Upgrade = default(StringValues); + return true; } + return false; } - break; - case 5: + if (ReferenceEquals(HeaderNames.Warning, key)) { - if ("Allow".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x200L) != 0) { - if ((_bits & 0x400L) == 0) - { - _bits |= 0x400L; - _headers._Allow = value; - return true; - } - return false; + _bits &= ~0x200L; + _headers._Warning = default(StringValues); + return true; } + return false; } - break; - case 12: + if (ReferenceEquals(HeaderNames.Expires, key)) { - if ("Content-Type".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x20000L) != 0) { - if ((_bits & 0x800L) == 0) - { - _bits |= 0x800L; - _headers._ContentType = value; - return true; - } - return false; + _bits &= ~0x20000L; + _headers._Expires = default(StringValues); + return true; } + return false; } - break; - case 16: + + if (HeaderNames.Trailer.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Content-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x20L) != 0) { - if ((_bits & 0x1000L) == 0) - { - _bits |= 0x1000L; - _headers._ContentEncoding = value; - return true; - } - return false; + _bits &= ~0x20L; + _headers._Trailer = default(StringValues); + return true; } - if ("Content-Language".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (HeaderNames.Upgrade.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x80L) != 0) { - if ((_bits & 0x2000L) == 0) - { - _bits |= 0x2000L; - _headers._ContentLanguage = value; - return true; - } - return false; + _bits &= ~0x80L; + _headers._Upgrade = default(StringValues); + return true; } - if ("Content-Location".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (HeaderNames.Warning.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x200L) != 0) { - if ((_bits & 0x4000L) == 0) - { - _bits |= 0x4000L; - _headers._ContentLocation = value; - return true; - } - return false; + _bits &= ~0x200L; + _headers._Warning = default(StringValues); + return true; } - if ("WWW-Authenticate".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (HeaderNames.Expires.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x20000L) != 0) { - if ((_bits & 0x10000000L) == 0) - { - _bits |= 0x10000000L; - _headers._WWWAuthenticate = value; - return true; - } - return false; + _bits &= ~0x20000L; + _headers._Expires = default(StringValues); + return true; } + return false; } break; - case 11: + } + case 8: + { + if (ReferenceEquals(HeaderNames.Location, key)) { - if ("Content-MD5".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x400000L) != 0) { - if ((_bits & 0x8000L) == 0) - { - _bits |= 0x8000L; - _headers._ContentMD5 = value; - return true; - } - return false; + _bits &= ~0x400000L; + _headers._Location = default(StringValues); + return true; } - if ("Retry-After".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + + if (HeaderNames.Location.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x400000L) != 0) { - if ((_bits & 0x1000000L) == 0) - { - _bits |= 0x1000000L; - _headers._RetryAfter = value; - return true; - } - return false; + _bits &= ~0x400000L; + _headers._Location = default(StringValues); + return true; } + return false; } break; - case 8: + } + case 10: + { + if (ReferenceEquals(HeaderNames.Connection, key)) { - if ("Location".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x2L) != 0) { - if ((_bits & 0x400000L) == 0) - { - _bits |= 0x400000L; - _headers._Location = value; - return true; - } - return false; + _bits &= ~0x2L; + _headers._Connection = default(StringValues); + _headers._rawConnection = null; + return true; } + return false; } - break; - case 18: + if (ReferenceEquals(HeaderNames.KeepAlive, key)) { - if ("Proxy-Authenticate".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x8L) != 0) { - if ((_bits & 0x800000L) == 0) - { - _bits |= 0x800000L; - _headers._ProxyAuthenticate = value; - return true; - } - return false; + _bits &= ~0x8L; + _headers._KeepAlive = default(StringValues); + return true; } + return false; } - break; - case 32: + if (ReferenceEquals(HeaderNames.SetCookie, key)) { - if ("Access-Control-Allow-Credentials".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x4000000L) != 0) { - if ((_bits & 0x20000000L) == 0) - { - _bits |= 0x20000000L; - _headers._AccessControlAllowCredentials = value; - return true; - } - return false; + _bits &= ~0x4000000L; + _headers._SetCookie = default(StringValues); + return true; } + return false; } - break; - case 28: + + if (HeaderNames.Connection.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Access-Control-Allow-Headers".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x2L) != 0) { - if ((_bits & 0x40000000L) == 0) - { - _bits |= 0x40000000L; - _headers._AccessControlAllowHeaders = value; - return true; - } - return false; + _bits &= ~0x2L; + _headers._Connection = default(StringValues); + _headers._rawConnection = null; + return true; } - if ("Access-Control-Allow-Methods".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (HeaderNames.KeepAlive.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x8L) != 0) { - if ((_bits & 0x80000000L) == 0) - { - _bits |= 0x80000000L; - _headers._AccessControlAllowMethods = value; - return true; - } - return false; + _bits &= ~0x8L; + _headers._KeepAlive = default(StringValues); + return true; } + return false; } - break; - case 27: + if (HeaderNames.SetCookie.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Access-Control-Allow-Origin".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x4000000L) != 0) { - if ((_bits & 0x100000000L) == 0) - { - _bits |= 0x100000000L; - _headers._AccessControlAllowOrigin = value; - return true; - } - return false; + _bits &= ~0x4000000L; + _headers._SetCookie = default(StringValues); + return true; } + return false; } break; - case 29: + } + case 11: + { + if (ReferenceEquals(HeaderNames.ContentMD5, key)) { - if ("Access-Control-Expose-Headers".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x8000L) != 0) { - if ((_bits & 0x200000000L) == 0) - { - _bits |= 0x200000000L; - _headers._AccessControlExposeHeaders = value; - return true; - } - return false; + _bits &= ~0x8000L; + _headers._ContentMD5 = default(StringValues); + return true; } + return false; } - break; - case 22: + if (ReferenceEquals(HeaderNames.RetryAfter, key)) { - if ("Access-Control-Max-Age".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x1000000L) != 0) { - if ((_bits & 0x400000000L) == 0) - { - _bits |= 0x400000000L; - _headers._AccessControlMaxAge = value; - return true; - } - return false; + _bits &= ~0x1000000L; + _headers._RetryAfter = default(StringValues); + return true; } + return false; } - break; - case 14: + + if (HeaderNames.ContentMD5.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Content-Length".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x8000L) != 0) { - if (!_contentLength.HasValue) - { - _contentLength = ParseContentLength(value); - return true; - } - return false; + _bits &= ~0x8000L; + _headers._ContentMD5 = default(StringValues); + return true; + } + return false; + } + if (HeaderNames.RetryAfter.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x1000000L) != 0) + { + _bits &= ~0x1000000L; + _headers._RetryAfter = default(StringValues); + return true; } + return false; } break; - } - - ValidateHeaderNameCharacters(key); - Unknown.Add(key, value); - // Return true, above will throw and exit for false - return true; - } - - protected override bool RemoveFast(string key) - { - switch (key.Length) - { - case 13: + } + case 12: + { + if (ReferenceEquals(HeaderNames.ContentType, key)) { - if ("Cache-Control".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x800L) != 0) { - if ((_bits & 0x1L) != 0) - { - _bits &= ~0x1L; - _headers._CacheControl = default(StringValues); - return true; - } - return false; + _bits &= ~0x800L; + _headers._ContentType = default(StringValues); + return true; } - if ("Content-Range".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + + if (HeaderNames.ContentType.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x800L) != 0) { - if ((_bits & 0x10000L) != 0) - { - _bits &= ~0x10000L; - _headers._ContentRange = default(StringValues); - return true; - } - return false; + _bits &= ~0x800L; + _headers._ContentType = default(StringValues); + return true; } - if ("Last-Modified".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + break; + } + case 13: + { + if (ReferenceEquals(HeaderNames.CacheControl, key)) + { + if ((_bits & 0x1L) != 0) { - if ((_bits & 0x40000L) != 0) - { - _bits &= ~0x40000L; - _headers._LastModified = default(StringValues); - return true; - } - return false; + _bits &= ~0x1L; + _headers._CacheControl = default(StringValues); + return true; } - if ("Accept-Ranges".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (ReferenceEquals(HeaderNames.ContentRange, key)) + { + if ((_bits & 0x10000L) != 0) { - if ((_bits & 0x80000L) != 0) - { - _bits &= ~0x80000L; - _headers._AcceptRanges = default(StringValues); - return true; - } - return false; + _bits &= ~0x10000L; + _headers._ContentRange = default(StringValues); + return true; } + return false; } - break; - case 10: + if (ReferenceEquals(HeaderNames.LastModified, key)) { - if ("Connection".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x40000L) != 0) { - if ((_bits & 0x2L) != 0) - { - _bits &= ~0x2L; - _headers._Connection = default(StringValues); - _headers._rawConnection = null; - return true; - } - return false; + _bits &= ~0x40000L; + _headers._LastModified = default(StringValues); + return true; } - if ("Keep-Alive".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (ReferenceEquals(HeaderNames.AcceptRanges, key)) + { + if ((_bits & 0x80000L) != 0) { - if ((_bits & 0x8L) != 0) - { - _bits &= ~0x8L; - _headers._KeepAlive = default(StringValues); - return true; - } - return false; + _bits &= ~0x80000L; + _headers._AcceptRanges = default(StringValues); + return true; } - if ("Set-Cookie".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + + if (HeaderNames.CacheControl.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x1L) != 0) { - if ((_bits & 0x4000000L) != 0) - { - _bits &= ~0x4000000L; - _headers._SetCookie = default(StringValues); - return true; - } - return false; + _bits &= ~0x1L; + _headers._CacheControl = default(StringValues); + return true; } + return false; } - break; - case 4: + if (HeaderNames.ContentRange.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Date".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x10000L) != 0) { - if ((_bits & 0x4L) != 0) - { - _bits &= ~0x4L; - _headers._Date = default(StringValues); - _headers._rawDate = null; - return true; - } - return false; + _bits &= ~0x10000L; + _headers._ContentRange = default(StringValues); + return true; } - if ("ETag".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (HeaderNames.LastModified.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x40000L) != 0) { - if ((_bits & 0x200000L) != 0) - { - _bits &= ~0x200000L; - _headers._ETag = default(StringValues); - return true; - } - return false; + _bits &= ~0x40000L; + _headers._LastModified = default(StringValues); + return true; } - if ("Vary".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (HeaderNames.AcceptRanges.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x80000L) != 0) { - if ((_bits & 0x8000000L) != 0) - { - _bits &= ~0x8000000L; - _headers._Vary = default(StringValues); - return true; - } - return false; + _bits &= ~0x80000L; + _headers._AcceptRanges = default(StringValues); + return true; } + return false; } break; - case 6: + } + case 14: + { + if (ReferenceEquals(HeaderNames.ContentLength, key)) { - if ("Pragma".Equals(key, StringComparison.OrdinalIgnoreCase)) + if (_contentLength.HasValue) { - if ((_bits & 0x10L) != 0) - { - _bits &= ~0x10L; - _headers._Pragma = default(StringValues); - return true; - } - return false; + _contentLength = null; + return true; } - if ("Server".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + + if (HeaderNames.ContentLength.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if (_contentLength.HasValue) { - if ((_bits & 0x2000000L) != 0) - { - _bits &= ~0x2000000L; - _headers._Server = default(StringValues); - _headers._rawServer = null; - return true; - } - return false; + _contentLength = null; + return true; } + return false; } break; - case 7: + } + case 16: + { + if (ReferenceEquals(HeaderNames.ContentEncoding, key)) { - if ("Trailer".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if ((_bits & 0x20L) != 0) - { - _bits &= ~0x20L; - _headers._Trailer = default(StringValues); - return true; - } - return false; - } - if ("Upgrade".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x1000L) != 0) { - if ((_bits & 0x80L) != 0) - { - _bits &= ~0x80L; - _headers._Upgrade = default(StringValues); - return true; - } - return false; + _bits &= ~0x1000L; + _headers._ContentEncoding = default(StringValues); + return true; } - if ("Warning".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (ReferenceEquals(HeaderNames.ContentLanguage, key)) + { + if ((_bits & 0x2000L) != 0) { - if ((_bits & 0x200L) != 0) - { - _bits &= ~0x200L; - _headers._Warning = default(StringValues); - return true; - } - return false; + _bits &= ~0x2000L; + _headers._ContentLanguage = default(StringValues); + return true; } - if ("Expires".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (ReferenceEquals(HeaderNames.ContentLocation, key)) + { + if ((_bits & 0x4000L) != 0) { - if ((_bits & 0x20000L) != 0) - { - _bits &= ~0x20000L; - _headers._Expires = default(StringValues); - return true; - } - return false; + _bits &= ~0x4000L; + _headers._ContentLocation = default(StringValues); + return true; } + return false; } - break; - case 17: + if (ReferenceEquals(HeaderNames.WWWAuthenticate, key)) { - if ("Transfer-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x10000000L) != 0) { - if ((_bits & 0x40L) != 0) - { - _bits &= ~0x40L; - _headers._TransferEncoding = default(StringValues); - _headers._rawTransferEncoding = null; - return true; - } - return false; + _bits &= ~0x10000000L; + _headers._WWWAuthenticate = default(StringValues); + return true; } + return false; } - break; - case 3: + + if (HeaderNames.ContentEncoding.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Via".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x1000L) != 0) { - if ((_bits & 0x100L) != 0) - { - _bits &= ~0x100L; - _headers._Via = default(StringValues); - return true; - } - return false; + _bits &= ~0x1000L; + _headers._ContentEncoding = default(StringValues); + return true; } - if ("Age".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + if (HeaderNames.ContentLanguage.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x2000L) != 0) { - if ((_bits & 0x100000L) != 0) - { - _bits &= ~0x100000L; - _headers._Age = default(StringValues); - return true; - } - return false; + _bits &= ~0x2000L; + _headers._ContentLanguage = default(StringValues); + return true; } + return false; } - break; - case 5: + if (HeaderNames.ContentLocation.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Allow".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x4000L) != 0) { - if ((_bits & 0x400L) != 0) - { - _bits &= ~0x400L; - _headers._Allow = default(StringValues); - return true; - } - return false; + _bits &= ~0x4000L; + _headers._ContentLocation = default(StringValues); + return true; } + return false; } - break; - case 12: + if (HeaderNames.WWWAuthenticate.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Content-Type".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x10000000L) != 0) { - if ((_bits & 0x800L) != 0) - { - _bits &= ~0x800L; - _headers._ContentType = default(StringValues); - return true; - } - return false; + _bits &= ~0x10000000L; + _headers._WWWAuthenticate = default(StringValues); + return true; } + return false; } break; - case 16: + } + case 17: + { + if (ReferenceEquals(HeaderNames.TransferEncoding, key)) { - if ("Content-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x40L) != 0) { - if ((_bits & 0x1000L) != 0) - { - _bits &= ~0x1000L; - _headers._ContentEncoding = default(StringValues); - return true; - } - return false; + _bits &= ~0x40L; + _headers._TransferEncoding = default(StringValues); + _headers._rawTransferEncoding = null; + return true; } - if ("Content-Language".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + + if (HeaderNames.TransferEncoding.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x40L) != 0) { - if ((_bits & 0x2000L) != 0) - { - _bits &= ~0x2000L; - _headers._ContentLanguage = default(StringValues); - return true; - } - return false; + _bits &= ~0x40L; + _headers._TransferEncoding = default(StringValues); + _headers._rawTransferEncoding = null; + return true; } - if ("Content-Location".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + break; + } + case 18: + { + if (ReferenceEquals(HeaderNames.ProxyAuthenticate, key)) + { + if ((_bits & 0x800000L) != 0) { - if ((_bits & 0x4000L) != 0) - { - _bits &= ~0x4000L; - _headers._ContentLocation = default(StringValues); - return true; - } - return false; + _bits &= ~0x800000L; + _headers._ProxyAuthenticate = default(StringValues); + return true; } - if ("WWW-Authenticate".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + + if (HeaderNames.ProxyAuthenticate.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x800000L) != 0) { - if ((_bits & 0x10000000L) != 0) - { - _bits &= ~0x10000000L; - _headers._WWWAuthenticate = default(StringValues); - return true; - } - return false; + _bits &= ~0x800000L; + _headers._ProxyAuthenticate = default(StringValues); + return true; } + return false; } break; - case 11: + } + case 22: + { + if (ReferenceEquals(HeaderNames.AccessControlMaxAge, key)) { - if ("Content-MD5".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x400000000L) != 0) { - if ((_bits & 0x8000L) != 0) - { - _bits &= ~0x8000L; - _headers._ContentMD5 = default(StringValues); - return true; - } - return false; + _bits &= ~0x400000000L; + _headers._AccessControlMaxAge = default(StringValues); + return true; } - if ("Retry-After".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + + if (HeaderNames.AccessControlMaxAge.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x400000000L) != 0) { - if ((_bits & 0x1000000L) != 0) - { - _bits &= ~0x1000000L; - _headers._RetryAfter = default(StringValues); - return true; - } - return false; + _bits &= ~0x400000000L; + _headers._AccessControlMaxAge = default(StringValues); + return true; } + return false; } break; - case 8: + } + case 27: + { + if (ReferenceEquals(HeaderNames.AccessControlAllowOrigin, key)) { - if ("Location".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x100000000L) != 0) { - if ((_bits & 0x400000L) != 0) - { - _bits &= ~0x400000L; - _headers._Location = default(StringValues); - return true; - } - return false; + _bits &= ~0x100000000L; + _headers._AccessControlAllowOrigin = default(StringValues); + return true; } + return false; } - break; - case 18: + + if (HeaderNames.AccessControlAllowOrigin.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Proxy-Authenticate".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x100000000L) != 0) { - if ((_bits & 0x800000L) != 0) - { - _bits &= ~0x800000L; - _headers._ProxyAuthenticate = default(StringValues); - return true; - } - return false; + _bits &= ~0x100000000L; + _headers._AccessControlAllowOrigin = default(StringValues); + return true; } + return false; } break; - case 32: + } + case 28: + { + if (ReferenceEquals(HeaderNames.AccessControlAllowHeaders, key)) { - if ("Access-Control-Allow-Credentials".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x40000000L) != 0) { - if ((_bits & 0x20000000L) != 0) - { - _bits &= ~0x20000000L; - _headers._AccessControlAllowCredentials = default(StringValues); - return true; - } - return false; + _bits &= ~0x40000000L; + _headers._AccessControlAllowHeaders = default(StringValues); + return true; } + return false; } - break; - case 28: + if (ReferenceEquals(HeaderNames.AccessControlAllowMethods, key)) { - if ("Access-Control-Allow-Headers".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x80000000L) != 0) { - if ((_bits & 0x40000000L) != 0) - { - _bits &= ~0x40000000L; - _headers._AccessControlAllowHeaders = default(StringValues); - return true; - } - return false; + _bits &= ~0x80000000L; + _headers._AccessControlAllowMethods = default(StringValues); + return true; } - if ("Access-Control-Allow-Methods".Equals(key, StringComparison.OrdinalIgnoreCase)) + return false; + } + + if (HeaderNames.AccessControlAllowHeaders.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x40000000L) != 0) { - if ((_bits & 0x80000000L) != 0) - { - _bits &= ~0x80000000L; - _headers._AccessControlAllowMethods = default(StringValues); - return true; - } - return false; + _bits &= ~0x40000000L; + _headers._AccessControlAllowHeaders = default(StringValues); + return true; } + return false; } - break; - case 27: + if (HeaderNames.AccessControlAllowMethods.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Access-Control-Allow-Origin".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x80000000L) != 0) { - if ((_bits & 0x100000000L) != 0) - { - _bits &= ~0x100000000L; - _headers._AccessControlAllowOrigin = default(StringValues); - return true; - } - return false; + _bits &= ~0x80000000L; + _headers._AccessControlAllowMethods = default(StringValues); + return true; } + return false; } break; + } case 29: + { + if (ReferenceEquals(HeaderNames.AccessControlExposeHeaders, key)) { - if ("Access-Control-Expose-Headers".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x200000000L) != 0) { - if ((_bits & 0x200000000L) != 0) - { - _bits &= ~0x200000000L; - _headers._AccessControlExposeHeaders = default(StringValues); - return true; - } - return false; + _bits &= ~0x200000000L; + _headers._AccessControlExposeHeaders = default(StringValues); + return true; } + return false; } - break; - case 22: + + if (HeaderNames.AccessControlExposeHeaders.Equals(key, StringComparison.OrdinalIgnoreCase)) { - if ("Access-Control-Max-Age".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x200000000L) != 0) { - if ((_bits & 0x400000000L) != 0) - { - _bits &= ~0x400000000L; - _headers._AccessControlMaxAge = default(StringValues); - return true; - } - return false; + _bits &= ~0x200000000L; + _headers._AccessControlExposeHeaders = default(StringValues); + return true; } + return false; } break; - case 14: + } + case 32: + { + if (ReferenceEquals(HeaderNames.AccessControlAllowCredentials, key)) { - if ("Content-Length".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x20000000L) != 0) { - if (_contentLength.HasValue) - { - _contentLength = null; - return true; - } - return false; + _bits &= ~0x20000000L; + _headers._AccessControlAllowCredentials = default(StringValues); + return true; + } + return false; + } + + if (HeaderNames.AccessControlAllowCredentials.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x20000000L) != 0) + { + _bits &= ~0x20000000L; + _headers._AccessControlAllowCredentials = default(StringValues); + return true; } + return false; } break; + } } - return MaybeUnknown?.Remove(key) ?? false; + return RemoveUnknown(key); } protected override void ClearFast() { @@ -6772,7 +10283,7 @@ protected override void ClearFast() if ((tempBits & 0x2L) != 0) { - _headers._Connection = default(StringValues); + _headers._Connection = default; if((tempBits & ~0x2L) == 0) { return; @@ -6782,7 +10293,7 @@ protected override void ClearFast() if ((tempBits & 0x4L) != 0) { - _headers._Date = default(StringValues); + _headers._Date = default; if((tempBits & ~0x4L) == 0) { return; @@ -6792,7 +10303,7 @@ protected override void ClearFast() if ((tempBits & 0x800L) != 0) { - _headers._ContentType = default(StringValues); + _headers._ContentType = default; if((tempBits & ~0x800L) == 0) { return; @@ -6802,7 +10313,7 @@ protected override void ClearFast() if ((tempBits & 0x2000000L) != 0) { - _headers._Server = default(StringValues); + _headers._Server = default; if((tempBits & ~0x2000000L) == 0) { return; @@ -6812,7 +10323,7 @@ protected override void ClearFast() if ((tempBits & 0x1L) != 0) { - _headers._CacheControl = default(StringValues); + _headers._CacheControl = default; if((tempBits & ~0x1L) == 0) { return; @@ -6822,7 +10333,7 @@ protected override void ClearFast() if ((tempBits & 0x8L) != 0) { - _headers._KeepAlive = default(StringValues); + _headers._KeepAlive = default; if((tempBits & ~0x8L) == 0) { return; @@ -6832,7 +10343,7 @@ protected override void ClearFast() if ((tempBits & 0x10L) != 0) { - _headers._Pragma = default(StringValues); + _headers._Pragma = default; if((tempBits & ~0x10L) == 0) { return; @@ -6842,7 +10353,7 @@ protected override void ClearFast() if ((tempBits & 0x20L) != 0) { - _headers._Trailer = default(StringValues); + _headers._Trailer = default; if((tempBits & ~0x20L) == 0) { return; @@ -6852,7 +10363,7 @@ protected override void ClearFast() if ((tempBits & 0x40L) != 0) { - _headers._TransferEncoding = default(StringValues); + _headers._TransferEncoding = default; if((tempBits & ~0x40L) == 0) { return; @@ -6862,7 +10373,7 @@ protected override void ClearFast() if ((tempBits & 0x80L) != 0) { - _headers._Upgrade = default(StringValues); + _headers._Upgrade = default; if((tempBits & ~0x80L) == 0) { return; @@ -6872,7 +10383,7 @@ protected override void ClearFast() if ((tempBits & 0x100L) != 0) { - _headers._Via = default(StringValues); + _headers._Via = default; if((tempBits & ~0x100L) == 0) { return; @@ -6882,7 +10393,7 @@ protected override void ClearFast() if ((tempBits & 0x200L) != 0) { - _headers._Warning = default(StringValues); + _headers._Warning = default; if((tempBits & ~0x200L) == 0) { return; @@ -6892,7 +10403,7 @@ protected override void ClearFast() if ((tempBits & 0x400L) != 0) { - _headers._Allow = default(StringValues); + _headers._Allow = default; if((tempBits & ~0x400L) == 0) { return; @@ -6902,7 +10413,7 @@ protected override void ClearFast() if ((tempBits & 0x1000L) != 0) { - _headers._ContentEncoding = default(StringValues); + _headers._ContentEncoding = default; if((tempBits & ~0x1000L) == 0) { return; @@ -6912,7 +10423,7 @@ protected override void ClearFast() if ((tempBits & 0x2000L) != 0) { - _headers._ContentLanguage = default(StringValues); + _headers._ContentLanguage = default; if((tempBits & ~0x2000L) == 0) { return; @@ -6922,7 +10433,7 @@ protected override void ClearFast() if ((tempBits & 0x4000L) != 0) { - _headers._ContentLocation = default(StringValues); + _headers._ContentLocation = default; if((tempBits & ~0x4000L) == 0) { return; @@ -6932,7 +10443,7 @@ protected override void ClearFast() if ((tempBits & 0x8000L) != 0) { - _headers._ContentMD5 = default(StringValues); + _headers._ContentMD5 = default; if((tempBits & ~0x8000L) == 0) { return; @@ -6942,7 +10453,7 @@ protected override void ClearFast() if ((tempBits & 0x10000L) != 0) { - _headers._ContentRange = default(StringValues); + _headers._ContentRange = default; if((tempBits & ~0x10000L) == 0) { return; @@ -6952,7 +10463,7 @@ protected override void ClearFast() if ((tempBits & 0x20000L) != 0) { - _headers._Expires = default(StringValues); + _headers._Expires = default; if((tempBits & ~0x20000L) == 0) { return; @@ -6962,7 +10473,7 @@ protected override void ClearFast() if ((tempBits & 0x40000L) != 0) { - _headers._LastModified = default(StringValues); + _headers._LastModified = default; if((tempBits & ~0x40000L) == 0) { return; @@ -6972,7 +10483,7 @@ protected override void ClearFast() if ((tempBits & 0x80000L) != 0) { - _headers._AcceptRanges = default(StringValues); + _headers._AcceptRanges = default; if((tempBits & ~0x80000L) == 0) { return; @@ -6982,7 +10493,7 @@ protected override void ClearFast() if ((tempBits & 0x100000L) != 0) { - _headers._Age = default(StringValues); + _headers._Age = default; if((tempBits & ~0x100000L) == 0) { return; @@ -6992,7 +10503,7 @@ protected override void ClearFast() if ((tempBits & 0x200000L) != 0) { - _headers._ETag = default(StringValues); + _headers._ETag = default; if((tempBits & ~0x200000L) == 0) { return; @@ -7002,7 +10513,7 @@ protected override void ClearFast() if ((tempBits & 0x400000L) != 0) { - _headers._Location = default(StringValues); + _headers._Location = default; if((tempBits & ~0x400000L) == 0) { return; @@ -7012,7 +10523,7 @@ protected override void ClearFast() if ((tempBits & 0x800000L) != 0) { - _headers._ProxyAuthenticate = default(StringValues); + _headers._ProxyAuthenticate = default; if((tempBits & ~0x800000L) == 0) { return; @@ -7022,7 +10533,7 @@ protected override void ClearFast() if ((tempBits & 0x1000000L) != 0) { - _headers._RetryAfter = default(StringValues); + _headers._RetryAfter = default; if((tempBits & ~0x1000000L) == 0) { return; @@ -7032,7 +10543,7 @@ protected override void ClearFast() if ((tempBits & 0x4000000L) != 0) { - _headers._SetCookie = default(StringValues); + _headers._SetCookie = default; if((tempBits & ~0x4000000L) == 0) { return; @@ -7042,7 +10553,7 @@ protected override void ClearFast() if ((tempBits & 0x8000000L) != 0) { - _headers._Vary = default(StringValues); + _headers._Vary = default; if((tempBits & ~0x8000000L) == 0) { return; @@ -7052,7 +10563,7 @@ protected override void ClearFast() if ((tempBits & 0x10000000L) != 0) { - _headers._WWWAuthenticate = default(StringValues); + _headers._WWWAuthenticate = default; if((tempBits & ~0x10000000L) == 0) { return; @@ -7062,7 +10573,7 @@ protected override void ClearFast() if ((tempBits & 0x20000000L) != 0) { - _headers._AccessControlAllowCredentials = default(StringValues); + _headers._AccessControlAllowCredentials = default; if((tempBits & ~0x20000000L) == 0) { return; @@ -7072,7 +10583,7 @@ protected override void ClearFast() if ((tempBits & 0x40000000L) != 0) { - _headers._AccessControlAllowHeaders = default(StringValues); + _headers._AccessControlAllowHeaders = default; if((tempBits & ~0x40000000L) == 0) { return; @@ -7082,7 +10593,7 @@ protected override void ClearFast() if ((tempBits & 0x80000000L) != 0) { - _headers._AccessControlAllowMethods = default(StringValues); + _headers._AccessControlAllowMethods = default; if((tempBits & ~0x80000000L) == 0) { return; @@ -7092,7 +10603,7 @@ protected override void ClearFast() if ((tempBits & 0x100000000L) != 0) { - _headers._AccessControlAllowOrigin = default(StringValues); + _headers._AccessControlAllowOrigin = default; if((tempBits & ~0x100000000L) == 0) { return; @@ -7102,7 +10613,7 @@ protected override void ClearFast() if ((tempBits & 0x200000000L) != 0) { - _headers._AccessControlExposeHeaders = default(StringValues); + _headers._AccessControlExposeHeaders = default; if((tempBits & ~0x200000000L) == 0) { return; @@ -7112,7 +10623,7 @@ protected override void ClearFast() if ((tempBits & 0x400000000L) != 0) { - _headers._AccessControlMaxAge = default(StringValues); + _headers._AccessControlMaxAge = default; if((tempBits & ~0x400000000L) == 0) { return; @@ -7135,7 +10646,7 @@ protected override bool CopyToFast(KeyValuePair[] array, i { return false; } - array[arrayIndex] = new KeyValuePair("Cache-Control", _headers._CacheControl); + array[arrayIndex] = new KeyValuePair(HeaderNames.CacheControl, _headers._CacheControl); ++arrayIndex; } if ((_bits & 0x2L) != 0) @@ -7144,7 +10655,7 @@ protected override bool CopyToFast(KeyValuePair[] array, i { return false; } - array[arrayIndex] = new KeyValuePair("Connection", _headers._Connection); + array[arrayIndex] = new KeyValuePair(HeaderNames.Connection, _headers._Connection); ++arrayIndex; } if ((_bits & 0x4L) != 0) @@ -7153,7 +10664,7 @@ protected override bool CopyToFast(KeyValuePair[] array, i { return false; } - array[arrayIndex] = new KeyValuePair("Date", _headers._Date); + array[arrayIndex] = new KeyValuePair(HeaderNames.Date, _headers._Date); ++arrayIndex; } if ((_bits & 0x8L) != 0) @@ -7162,7 +10673,7 @@ protected override bool CopyToFast(KeyValuePair[] array, i { return false; } - array[arrayIndex] = new KeyValuePair("Keep-Alive", _headers._KeepAlive); + array[arrayIndex] = new KeyValuePair(HeaderNames.KeepAlive, _headers._KeepAlive); ++arrayIndex; } if ((_bits & 0x10L) != 0) @@ -7171,7 +10682,7 @@ protected override bool CopyToFast(KeyValuePair[] array, i { return false; } - array[arrayIndex] = new KeyValuePair("Pragma", _headers._Pragma); + array[arrayIndex] = new KeyValuePair(HeaderNames.Pragma, _headers._Pragma); ++arrayIndex; } if ((_bits & 0x20L) != 0) @@ -7180,7 +10691,7 @@ protected override bool CopyToFast(KeyValuePair[] array, i { return false; } - array[arrayIndex] = new KeyValuePair("Trailer", _headers._Trailer); + array[arrayIndex] = new KeyValuePair(HeaderNames.Trailer, _headers._Trailer); ++arrayIndex; } if ((_bits & 0x40L) != 0) @@ -7189,7 +10700,7 @@ protected override bool CopyToFast(KeyValuePair[] array, i { return false; } - array[arrayIndex] = new KeyValuePair("Transfer-Encoding", _headers._TransferEncoding); + array[arrayIndex] = new KeyValuePair(HeaderNames.TransferEncoding, _headers._TransferEncoding); ++arrayIndex; } if ((_bits & 0x80L) != 0) @@ -7198,7 +10709,7 @@ protected override bool CopyToFast(KeyValuePair[] array, i { return false; } - array[arrayIndex] = new KeyValuePair("Upgrade", _headers._Upgrade); + array[arrayIndex] = new KeyValuePair(HeaderNames.Upgrade, _headers._Upgrade); ++arrayIndex; } if ((_bits & 0x100L) != 0) @@ -7207,7 +10718,7 @@ protected override bool CopyToFast(KeyValuePair[] array, i { return false; } - array[arrayIndex] = new KeyValuePair("Via", _headers._Via); + array[arrayIndex] = new KeyValuePair(HeaderNames.Via, _headers._Via); ++arrayIndex; } if ((_bits & 0x200L) != 0) @@ -7216,7 +10727,7 @@ protected override bool CopyToFast(KeyValuePair[] array, i { return false; } - array[arrayIndex] = new KeyValuePair("Warning", _headers._Warning); + array[arrayIndex] = new KeyValuePair(HeaderNames.Warning, _headers._Warning); ++arrayIndex; } if ((_bits & 0x400L) != 0) @@ -7225,7 +10736,7 @@ protected override bool CopyToFast(KeyValuePair[] array, i { return false; } - array[arrayIndex] = new KeyValuePair("Allow", _headers._Allow); + array[arrayIndex] = new KeyValuePair(HeaderNames.Allow, _headers._Allow); ++arrayIndex; } if ((_bits & 0x800L) != 0) @@ -7234,7 +10745,7 @@ protected override bool CopyToFast(KeyValuePair[] array, i { return false; } - array[arrayIndex] = new KeyValuePair("Content-Type", _headers._ContentType); + array[arrayIndex] = new KeyValuePair(HeaderNames.ContentType, _headers._ContentType); ++arrayIndex; } if ((_bits & 0x1000L) != 0) @@ -7243,7 +10754,7 @@ protected override bool CopyToFast(KeyValuePair[] array, i { return false; } - array[arrayIndex] = new KeyValuePair("Content-Encoding", _headers._ContentEncoding); + array[arrayIndex] = new KeyValuePair(HeaderNames.ContentEncoding, _headers._ContentEncoding); ++arrayIndex; } if ((_bits & 0x2000L) != 0) @@ -7252,7 +10763,7 @@ protected override bool CopyToFast(KeyValuePair[] array, i { return false; } - array[arrayIndex] = new KeyValuePair("Content-Language", _headers._ContentLanguage); + array[arrayIndex] = new KeyValuePair(HeaderNames.ContentLanguage, _headers._ContentLanguage); ++arrayIndex; } if ((_bits & 0x4000L) != 0) @@ -7261,7 +10772,7 @@ protected override bool CopyToFast(KeyValuePair[] array, i { return false; } - array[arrayIndex] = new KeyValuePair("Content-Location", _headers._ContentLocation); + array[arrayIndex] = new KeyValuePair(HeaderNames.ContentLocation, _headers._ContentLocation); ++arrayIndex; } if ((_bits & 0x8000L) != 0) @@ -7270,7 +10781,7 @@ protected override bool CopyToFast(KeyValuePair[] array, i { return false; } - array[arrayIndex] = new KeyValuePair("Content-MD5", _headers._ContentMD5); + array[arrayIndex] = new KeyValuePair(HeaderNames.ContentMD5, _headers._ContentMD5); ++arrayIndex; } if ((_bits & 0x10000L) != 0) @@ -7279,7 +10790,7 @@ protected override bool CopyToFast(KeyValuePair[] array, i { return false; } - array[arrayIndex] = new KeyValuePair("Content-Range", _headers._ContentRange); + array[arrayIndex] = new KeyValuePair(HeaderNames.ContentRange, _headers._ContentRange); ++arrayIndex; } if ((_bits & 0x20000L) != 0) @@ -7288,7 +10799,7 @@ protected override bool CopyToFast(KeyValuePair[] array, i { return false; } - array[arrayIndex] = new KeyValuePair("Expires", _headers._Expires); + array[arrayIndex] = new KeyValuePair(HeaderNames.Expires, _headers._Expires); ++arrayIndex; } if ((_bits & 0x40000L) != 0) @@ -7297,7 +10808,7 @@ protected override bool CopyToFast(KeyValuePair[] array, i { return false; } - array[arrayIndex] = new KeyValuePair("Last-Modified", _headers._LastModified); + array[arrayIndex] = new KeyValuePair(HeaderNames.LastModified, _headers._LastModified); ++arrayIndex; } if ((_bits & 0x80000L) != 0) @@ -7306,7 +10817,7 @@ protected override bool CopyToFast(KeyValuePair[] array, i { return false; } - array[arrayIndex] = new KeyValuePair("Accept-Ranges", _headers._AcceptRanges); + array[arrayIndex] = new KeyValuePair(HeaderNames.AcceptRanges, _headers._AcceptRanges); ++arrayIndex; } if ((_bits & 0x100000L) != 0) @@ -7315,7 +10826,7 @@ protected override bool CopyToFast(KeyValuePair[] array, i { return false; } - array[arrayIndex] = new KeyValuePair("Age", _headers._Age); + array[arrayIndex] = new KeyValuePair(HeaderNames.Age, _headers._Age); ++arrayIndex; } if ((_bits & 0x200000L) != 0) @@ -7324,7 +10835,7 @@ protected override bool CopyToFast(KeyValuePair[] array, i { return false; } - array[arrayIndex] = new KeyValuePair("ETag", _headers._ETag); + array[arrayIndex] = new KeyValuePair(HeaderNames.ETag, _headers._ETag); ++arrayIndex; } if ((_bits & 0x400000L) != 0) @@ -7333,7 +10844,7 @@ protected override bool CopyToFast(KeyValuePair[] array, i { return false; } - array[arrayIndex] = new KeyValuePair("Location", _headers._Location); + array[arrayIndex] = new KeyValuePair(HeaderNames.Location, _headers._Location); ++arrayIndex; } if ((_bits & 0x800000L) != 0) @@ -7342,7 +10853,7 @@ protected override bool CopyToFast(KeyValuePair[] array, i { return false; } - array[arrayIndex] = new KeyValuePair("Proxy-Authenticate", _headers._ProxyAuthenticate); + array[arrayIndex] = new KeyValuePair(HeaderNames.ProxyAuthenticate, _headers._ProxyAuthenticate); ++arrayIndex; } if ((_bits & 0x1000000L) != 0) @@ -7351,7 +10862,7 @@ protected override bool CopyToFast(KeyValuePair[] array, i { return false; } - array[arrayIndex] = new KeyValuePair("Retry-After", _headers._RetryAfter); + array[arrayIndex] = new KeyValuePair(HeaderNames.RetryAfter, _headers._RetryAfter); ++arrayIndex; } if ((_bits & 0x2000000L) != 0) @@ -7360,7 +10871,7 @@ protected override bool CopyToFast(KeyValuePair[] array, i { return false; } - array[arrayIndex] = new KeyValuePair("Server", _headers._Server); + array[arrayIndex] = new KeyValuePair(HeaderNames.Server, _headers._Server); ++arrayIndex; } if ((_bits & 0x4000000L) != 0) @@ -7369,7 +10880,7 @@ protected override bool CopyToFast(KeyValuePair[] array, i { return false; } - array[arrayIndex] = new KeyValuePair("Set-Cookie", _headers._SetCookie); + array[arrayIndex] = new KeyValuePair(HeaderNames.SetCookie, _headers._SetCookie); ++arrayIndex; } if ((_bits & 0x8000000L) != 0) @@ -7378,7 +10889,7 @@ protected override bool CopyToFast(KeyValuePair[] array, i { return false; } - array[arrayIndex] = new KeyValuePair("Vary", _headers._Vary); + array[arrayIndex] = new KeyValuePair(HeaderNames.Vary, _headers._Vary); ++arrayIndex; } if ((_bits & 0x10000000L) != 0) @@ -7387,7 +10898,7 @@ protected override bool CopyToFast(KeyValuePair[] array, i { return false; } - array[arrayIndex] = new KeyValuePair("WWW-Authenticate", _headers._WWWAuthenticate); + array[arrayIndex] = new KeyValuePair(HeaderNames.WWWAuthenticate, _headers._WWWAuthenticate); ++arrayIndex; } if ((_bits & 0x20000000L) != 0) @@ -7396,7 +10907,7 @@ protected override bool CopyToFast(KeyValuePair[] array, i { return false; } - array[arrayIndex] = new KeyValuePair("Access-Control-Allow-Credentials", _headers._AccessControlAllowCredentials); + array[arrayIndex] = new KeyValuePair(HeaderNames.AccessControlAllowCredentials, _headers._AccessControlAllowCredentials); ++arrayIndex; } if ((_bits & 0x40000000L) != 0) @@ -7405,7 +10916,7 @@ protected override bool CopyToFast(KeyValuePair[] array, i { return false; } - array[arrayIndex] = new KeyValuePair("Access-Control-Allow-Headers", _headers._AccessControlAllowHeaders); + array[arrayIndex] = new KeyValuePair(HeaderNames.AccessControlAllowHeaders, _headers._AccessControlAllowHeaders); ++arrayIndex; } if ((_bits & 0x80000000L) != 0) @@ -7414,7 +10925,7 @@ protected override bool CopyToFast(KeyValuePair[] array, i { return false; } - array[arrayIndex] = new KeyValuePair("Access-Control-Allow-Methods", _headers._AccessControlAllowMethods); + array[arrayIndex] = new KeyValuePair(HeaderNames.AccessControlAllowMethods, _headers._AccessControlAllowMethods); ++arrayIndex; } if ((_bits & 0x100000000L) != 0) @@ -7423,7 +10934,7 @@ protected override bool CopyToFast(KeyValuePair[] array, i { return false; } - array[arrayIndex] = new KeyValuePair("Access-Control-Allow-Origin", _headers._AccessControlAllowOrigin); + array[arrayIndex] = new KeyValuePair(HeaderNames.AccessControlAllowOrigin, _headers._AccessControlAllowOrigin); ++arrayIndex; } if ((_bits & 0x200000000L) != 0) @@ -7432,7 +10943,7 @@ protected override bool CopyToFast(KeyValuePair[] array, i { return false; } - array[arrayIndex] = new KeyValuePair("Access-Control-Expose-Headers", _headers._AccessControlExposeHeaders); + array[arrayIndex] = new KeyValuePair(HeaderNames.AccessControlExposeHeaders, _headers._AccessControlExposeHeaders); ++arrayIndex; } if ((_bits & 0x400000000L) != 0) @@ -7441,7 +10952,7 @@ protected override bool CopyToFast(KeyValuePair[] array, i { return false; } - array[arrayIndex] = new KeyValuePair("Access-Control-Max-Age", _headers._AccessControlMaxAge); + array[arrayIndex] = new KeyValuePair(HeaderNames.AccessControlMaxAge, _headers._AccessControlMaxAge); ++arrayIndex; } if (_contentLength.HasValue) @@ -7450,7 +10961,7 @@ protected override bool CopyToFast(KeyValuePair[] array, i { return false; } - array[arrayIndex] = new KeyValuePair("Content-Length", HeaderUtilities.FormatNonNegativeInt64(_contentLength.Value)); + array[arrayIndex] = new KeyValuePair(HeaderNames.ContentLength, HeaderUtilities.FormatNonNegativeInt64(_contentLength.Value)); ++arrayIndex; } ((ICollection>)MaybeUnknown)?.CopyTo(array, arrayIndex); @@ -8046,252 +11557,252 @@ public bool MoveNext() HeaderCacheControl: // case 0 if ((_bits & 0x1L) != 0) { - _current = new KeyValuePair("Cache-Control", _collection._headers._CacheControl); + _current = new KeyValuePair(HeaderNames.CacheControl, _collection._headers._CacheControl); _next = 1; return true; } HeaderConnection: // case 1 if ((_bits & 0x2L) != 0) { - _current = new KeyValuePair("Connection", _collection._headers._Connection); + _current = new KeyValuePair(HeaderNames.Connection, _collection._headers._Connection); _next = 2; return true; } HeaderDate: // case 2 if ((_bits & 0x4L) != 0) { - _current = new KeyValuePair("Date", _collection._headers._Date); + _current = new KeyValuePair(HeaderNames.Date, _collection._headers._Date); _next = 3; return true; } HeaderKeepAlive: // case 3 if ((_bits & 0x8L) != 0) { - _current = new KeyValuePair("Keep-Alive", _collection._headers._KeepAlive); + _current = new KeyValuePair(HeaderNames.KeepAlive, _collection._headers._KeepAlive); _next = 4; return true; } HeaderPragma: // case 4 if ((_bits & 0x10L) != 0) { - _current = new KeyValuePair("Pragma", _collection._headers._Pragma); + _current = new KeyValuePair(HeaderNames.Pragma, _collection._headers._Pragma); _next = 5; return true; } HeaderTrailer: // case 5 if ((_bits & 0x20L) != 0) { - _current = new KeyValuePair("Trailer", _collection._headers._Trailer); + _current = new KeyValuePair(HeaderNames.Trailer, _collection._headers._Trailer); _next = 6; return true; } HeaderTransferEncoding: // case 6 if ((_bits & 0x40L) != 0) { - _current = new KeyValuePair("Transfer-Encoding", _collection._headers._TransferEncoding); + _current = new KeyValuePair(HeaderNames.TransferEncoding, _collection._headers._TransferEncoding); _next = 7; return true; } HeaderUpgrade: // case 7 if ((_bits & 0x80L) != 0) { - _current = new KeyValuePair("Upgrade", _collection._headers._Upgrade); + _current = new KeyValuePair(HeaderNames.Upgrade, _collection._headers._Upgrade); _next = 8; return true; } HeaderVia: // case 8 if ((_bits & 0x100L) != 0) { - _current = new KeyValuePair("Via", _collection._headers._Via); + _current = new KeyValuePair(HeaderNames.Via, _collection._headers._Via); _next = 9; return true; } HeaderWarning: // case 9 if ((_bits & 0x200L) != 0) { - _current = new KeyValuePair("Warning", _collection._headers._Warning); + _current = new KeyValuePair(HeaderNames.Warning, _collection._headers._Warning); _next = 10; return true; } HeaderAllow: // case 10 if ((_bits & 0x400L) != 0) { - _current = new KeyValuePair("Allow", _collection._headers._Allow); + _current = new KeyValuePair(HeaderNames.Allow, _collection._headers._Allow); _next = 11; return true; } HeaderContentType: // case 11 if ((_bits & 0x800L) != 0) { - _current = new KeyValuePair("Content-Type", _collection._headers._ContentType); + _current = new KeyValuePair(HeaderNames.ContentType, _collection._headers._ContentType); _next = 12; return true; } HeaderContentEncoding: // case 12 if ((_bits & 0x1000L) != 0) { - _current = new KeyValuePair("Content-Encoding", _collection._headers._ContentEncoding); + _current = new KeyValuePair(HeaderNames.ContentEncoding, _collection._headers._ContentEncoding); _next = 13; return true; } HeaderContentLanguage: // case 13 if ((_bits & 0x2000L) != 0) { - _current = new KeyValuePair("Content-Language", _collection._headers._ContentLanguage); + _current = new KeyValuePair(HeaderNames.ContentLanguage, _collection._headers._ContentLanguage); _next = 14; return true; } HeaderContentLocation: // case 14 if ((_bits & 0x4000L) != 0) { - _current = new KeyValuePair("Content-Location", _collection._headers._ContentLocation); + _current = new KeyValuePair(HeaderNames.ContentLocation, _collection._headers._ContentLocation); _next = 15; return true; } HeaderContentMD5: // case 15 if ((_bits & 0x8000L) != 0) { - _current = new KeyValuePair("Content-MD5", _collection._headers._ContentMD5); + _current = new KeyValuePair(HeaderNames.ContentMD5, _collection._headers._ContentMD5); _next = 16; return true; } HeaderContentRange: // case 16 if ((_bits & 0x10000L) != 0) { - _current = new KeyValuePair("Content-Range", _collection._headers._ContentRange); + _current = new KeyValuePair(HeaderNames.ContentRange, _collection._headers._ContentRange); _next = 17; return true; } HeaderExpires: // case 17 if ((_bits & 0x20000L) != 0) { - _current = new KeyValuePair("Expires", _collection._headers._Expires); + _current = new KeyValuePair(HeaderNames.Expires, _collection._headers._Expires); _next = 18; return true; } HeaderLastModified: // case 18 if ((_bits & 0x40000L) != 0) { - _current = new KeyValuePair("Last-Modified", _collection._headers._LastModified); + _current = new KeyValuePair(HeaderNames.LastModified, _collection._headers._LastModified); _next = 19; return true; } HeaderAcceptRanges: // case 19 if ((_bits & 0x80000L) != 0) { - _current = new KeyValuePair("Accept-Ranges", _collection._headers._AcceptRanges); + _current = new KeyValuePair(HeaderNames.AcceptRanges, _collection._headers._AcceptRanges); _next = 20; return true; } HeaderAge: // case 20 if ((_bits & 0x100000L) != 0) { - _current = new KeyValuePair("Age", _collection._headers._Age); + _current = new KeyValuePair(HeaderNames.Age, _collection._headers._Age); _next = 21; return true; } HeaderETag: // case 21 if ((_bits & 0x200000L) != 0) { - _current = new KeyValuePair("ETag", _collection._headers._ETag); + _current = new KeyValuePair(HeaderNames.ETag, _collection._headers._ETag); _next = 22; return true; } HeaderLocation: // case 22 if ((_bits & 0x400000L) != 0) { - _current = new KeyValuePair("Location", _collection._headers._Location); + _current = new KeyValuePair(HeaderNames.Location, _collection._headers._Location); _next = 23; return true; } HeaderProxyAuthenticate: // case 23 if ((_bits & 0x800000L) != 0) { - _current = new KeyValuePair("Proxy-Authenticate", _collection._headers._ProxyAuthenticate); + _current = new KeyValuePair(HeaderNames.ProxyAuthenticate, _collection._headers._ProxyAuthenticate); _next = 24; return true; } HeaderRetryAfter: // case 24 if ((_bits & 0x1000000L) != 0) { - _current = new KeyValuePair("Retry-After", _collection._headers._RetryAfter); + _current = new KeyValuePair(HeaderNames.RetryAfter, _collection._headers._RetryAfter); _next = 25; return true; } HeaderServer: // case 25 if ((_bits & 0x2000000L) != 0) { - _current = new KeyValuePair("Server", _collection._headers._Server); + _current = new KeyValuePair(HeaderNames.Server, _collection._headers._Server); _next = 26; return true; } HeaderSetCookie: // case 26 if ((_bits & 0x4000000L) != 0) { - _current = new KeyValuePair("Set-Cookie", _collection._headers._SetCookie); + _current = new KeyValuePair(HeaderNames.SetCookie, _collection._headers._SetCookie); _next = 27; return true; } HeaderVary: // case 27 if ((_bits & 0x8000000L) != 0) { - _current = new KeyValuePair("Vary", _collection._headers._Vary); + _current = new KeyValuePair(HeaderNames.Vary, _collection._headers._Vary); _next = 28; return true; } HeaderWWWAuthenticate: // case 28 if ((_bits & 0x10000000L) != 0) { - _current = new KeyValuePair("WWW-Authenticate", _collection._headers._WWWAuthenticate); + _current = new KeyValuePair(HeaderNames.WWWAuthenticate, _collection._headers._WWWAuthenticate); _next = 29; return true; } HeaderAccessControlAllowCredentials: // case 29 if ((_bits & 0x20000000L) != 0) { - _current = new KeyValuePair("Access-Control-Allow-Credentials", _collection._headers._AccessControlAllowCredentials); + _current = new KeyValuePair(HeaderNames.AccessControlAllowCredentials, _collection._headers._AccessControlAllowCredentials); _next = 30; return true; } HeaderAccessControlAllowHeaders: // case 30 if ((_bits & 0x40000000L) != 0) { - _current = new KeyValuePair("Access-Control-Allow-Headers", _collection._headers._AccessControlAllowHeaders); + _current = new KeyValuePair(HeaderNames.AccessControlAllowHeaders, _collection._headers._AccessControlAllowHeaders); _next = 31; return true; } HeaderAccessControlAllowMethods: // case 31 if ((_bits & 0x80000000L) != 0) { - _current = new KeyValuePair("Access-Control-Allow-Methods", _collection._headers._AccessControlAllowMethods); + _current = new KeyValuePair(HeaderNames.AccessControlAllowMethods, _collection._headers._AccessControlAllowMethods); _next = 32; return true; } HeaderAccessControlAllowOrigin: // case 32 if ((_bits & 0x100000000L) != 0) { - _current = new KeyValuePair("Access-Control-Allow-Origin", _collection._headers._AccessControlAllowOrigin); + _current = new KeyValuePair(HeaderNames.AccessControlAllowOrigin, _collection._headers._AccessControlAllowOrigin); _next = 33; return true; } HeaderAccessControlExposeHeaders: // case 33 if ((_bits & 0x200000000L) != 0) { - _current = new KeyValuePair("Access-Control-Expose-Headers", _collection._headers._AccessControlExposeHeaders); + _current = new KeyValuePair(HeaderNames.AccessControlExposeHeaders, _collection._headers._AccessControlExposeHeaders); _next = 34; return true; } HeaderAccessControlMaxAge: // case 34 if ((_bits & 0x400000000L) != 0) { - _current = new KeyValuePair("Access-Control-Max-Age", _collection._headers._AccessControlMaxAge); + _current = new KeyValuePair(HeaderNames.AccessControlMaxAge, _collection._headers._AccessControlMaxAge); _next = 35; return true; } HeaderContentLength: // case 35 if (_collection._contentLength.HasValue) { - _current = new KeyValuePair("Content-Length", HeaderUtilities.FormatNonNegativeInt64(_collection._contentLength.Value)); + _current = new KeyValuePair(HeaderNames.ContentLength, HeaderUtilities.FormatNonNegativeInt64(_collection._contentLength.Value)); _next = 36; return true; } @@ -8346,21 +11857,31 @@ protected override bool TryGetValueFast(string key, out StringValues value) switch (key.Length) { case 4: + { + if (ReferenceEquals(HeaderNames.ETag, key)) { - if ("ETag".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x1L) != 0) { - if ((_bits & 0x1L) != 0) - { - value = _headers._ETag; - return true; - } - return false; + value = _headers._ETag; + return true; + } + return false; + } + + if (HeaderNames.ETag.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x1L) != 0) + { + value = _headers._ETag; + return true; } + return false; } break; + } } - return MaybeUnknown?.TryGetValue(key, out value) ?? false; + return TryGetUnknown(key, ref value); } protected override void SetValueFast(string key, StringValues value) @@ -8369,15 +11890,22 @@ protected override void SetValueFast(string key, StringValues value) switch (key.Length) { case 4: + { + if (ReferenceEquals(HeaderNames.ETag, key)) { - if ("ETag".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - _bits |= 0x1L; - _headers._ETag = value; - return; - } + _bits |= 0x1L; + _headers._ETag = value; + return; + } + + if (HeaderNames.ETag.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 0x1L; + _headers._ETag = value; + return; } break; + } } SetValueUnknown(key, value); @@ -8389,24 +11917,33 @@ protected override bool AddValueFast(string key, StringValues value) switch (key.Length) { case 4: + { + if (ReferenceEquals(HeaderNames.ETag, key)) { - if ("ETag".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x1L) == 0) { - if ((_bits & 0x1L) == 0) - { - _bits |= 0x1L; - _headers._ETag = value; - return true; - } - return false; + _bits |= 0x1L; + _headers._ETag = value; + return true; + } + return false; + } + + if (HeaderNames.ETag.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x1L) == 0) + { + _bits |= 0x1L; + _headers._ETag = value; + return true; } + return false; } break; + } } - Unknown.Add(key, value); - // Return true, above will throw and exit for false - return true; + return AddValueUnknown(key, value); } protected override bool RemoveFast(string key) @@ -8414,22 +11951,33 @@ protected override bool RemoveFast(string key) switch (key.Length) { case 4: + { + if (ReferenceEquals(HeaderNames.ETag, key)) { - if ("ETag".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ((_bits & 0x1L) != 0) { - if ((_bits & 0x1L) != 0) - { - _bits &= ~0x1L; - _headers._ETag = default(StringValues); - return true; - } - return false; + _bits &= ~0x1L; + _headers._ETag = default(StringValues); + return true; + } + return false; + } + + if (HeaderNames.ETag.Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if ((_bits & 0x1L) != 0) + { + _bits &= ~0x1L; + _headers._ETag = default(StringValues); + return true; } + return false; } break; + } } - return MaybeUnknown?.Remove(key) ?? false; + return RemoveUnknown(key); } protected override void ClearFast() { @@ -8445,7 +11993,7 @@ protected override void ClearFast() if ((tempBits & 0x1L) != 0) { - _headers._ETag = default(StringValues); + _headers._ETag = default; if((tempBits & ~0x1L) == 0) { return; @@ -8468,7 +12016,7 @@ protected override bool CopyToFast(KeyValuePair[] array, i { return false; } - array[arrayIndex] = new KeyValuePair("ETag", _headers._ETag); + array[arrayIndex] = new KeyValuePair(HeaderNames.ETag, _headers._ETag); ++arrayIndex; } if (_contentLength.HasValue) @@ -8477,7 +12025,7 @@ protected override bool CopyToFast(KeyValuePair[] array, i { return false; } - array[arrayIndex] = new KeyValuePair("Content-Length", HeaderUtilities.FormatNonNegativeInt64(_contentLength.Value)); + array[arrayIndex] = new KeyValuePair(HeaderNames.ContentLength, HeaderUtilities.FormatNonNegativeInt64(_contentLength.Value)); ++arrayIndex; } ((ICollection>)MaybeUnknown)?.CopyTo(array, arrayIndex); @@ -8509,7 +12057,7 @@ public bool MoveNext() HeaderETag: // case 0 if ((_bits & 0x1L) != 0) { - _current = new KeyValuePair("ETag", _collection._headers._ETag); + _current = new KeyValuePair(HeaderNames.ETag, _collection._headers._ETag); _next = 1; return true; } diff --git a/src/Servers/Kestrel/Core/src/Internal/Http/HttpHeaders.cs b/src/Servers/Kestrel/Core/src/Internal/Http/HttpHeaders.cs index b6944d80214d..efc935d20209 100644 --- a/src/Servers/Kestrel/Core/src/Internal/Http/HttpHeaders.cs +++ b/src/Servers/Kestrel/Core/src/Internal/Http/HttpHeaders.cs @@ -127,6 +127,12 @@ protected static StringValues AppendValue(StringValues existing, string append) return StringValues.Concat(existing, append); } + [MethodImpl(MethodImplOptions.NoInlining)] + protected bool TryGetUnknown(string key, ref StringValues value) => MaybeUnknown?.TryGetValue(key, out value) ?? false; + + [MethodImpl(MethodImplOptions.NoInlining)] + protected bool RemoveUnknown(string key) => MaybeUnknown?.Remove(key) ?? false; + [MethodImpl(MethodImplOptions.AggressiveInlining)] protected static int BitCount(long value) { diff --git a/src/Servers/Kestrel/Core/src/Internal/Http/HttpProtocol.FeatureCollection.cs b/src/Servers/Kestrel/Core/src/Internal/Http/HttpProtocol.FeatureCollection.cs index 4d80e6e14cd6..a91755587164 100644 --- a/src/Servers/Kestrel/Core/src/Internal/Http/HttpProtocol.FeatureCollection.cs +++ b/src/Servers/Kestrel/Core/src/Internal/Http/HttpProtocol.FeatureCollection.cs @@ -13,6 +13,7 @@ using Microsoft.AspNetCore.Server.Kestrel.Core.Features; using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure; using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal; +using Microsoft.Net.Http.Headers; namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http { @@ -302,7 +303,7 @@ async Task IHttpUpgradeFeature.UpgradeAsync() StatusCode = StatusCodes.Status101SwitchingProtocols; ReasonPhrase = "Switching Protocols"; - ResponseHeaders["Connection"] = "Upgrade"; + ResponseHeaders[HeaderNames.Connection] = "Upgrade"; await FlushAsync(); diff --git a/src/Servers/Kestrel/Core/src/Internal/Http/HttpProtocol.cs b/src/Servers/Kestrel/Core/src/Internal/Http/HttpProtocol.cs index 8131508a82a1..e7d2dd154bbb 100644 --- a/src/Servers/Kestrel/Core/src/Internal/Http/HttpProtocol.cs +++ b/src/Servers/Kestrel/Core/src/Internal/Http/HttpProtocol.cs @@ -20,6 +20,7 @@ using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Primitives; +using Microsoft.Net.Http.Headers; namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http { @@ -903,7 +904,7 @@ public void ProduceContinue() } if (_httpVersion != Http.HttpVersion.Http10 && - RequestHeaders.TryGetValue("Expect", out var expect) && + RequestHeaders.TryGetValue(HeaderNames.Expect, out var expect) && (expect.FirstOrDefault() ?? "").Equals("100-continue", StringComparison.OrdinalIgnoreCase)) { Output.Write100ContinueAsync().GetAwaiter().GetResult(); diff --git a/src/Servers/Kestrel/Core/src/Internal/Http/HttpRequestHeaders.cs b/src/Servers/Kestrel/Core/src/Internal/Http/HttpRequestHeaders.cs index 586987ebdf4d..ea3adc24baf6 100644 --- a/src/Servers/Kestrel/Core/src/Internal/Http/HttpRequestHeaders.cs +++ b/src/Servers/Kestrel/Core/src/Internal/Http/HttpRequestHeaders.cs @@ -92,6 +92,14 @@ private void SetValueUnknown(string key, StringValues value) Unknown[key] = value; } + [MethodImpl(MethodImplOptions.NoInlining)] + private bool AddValueUnknown(string key, StringValues value) + { + Unknown.Add(key, value); + // Return true, above will throw and exit for false + return true; + } + [MethodImpl(MethodImplOptions.NoInlining)] private unsafe void AppendUnknownHeaders(Span name, string valueString) { diff --git a/src/Servers/Kestrel/Core/src/Internal/Http/HttpResponseHeaders.cs b/src/Servers/Kestrel/Core/src/Internal/Http/HttpResponseHeaders.cs index 1e24c07178f9..6dff25ae5dc8 100644 --- a/src/Servers/Kestrel/Core/src/Internal/Http/HttpResponseHeaders.cs +++ b/src/Servers/Kestrel/Core/src/Internal/Http/HttpResponseHeaders.cs @@ -78,6 +78,15 @@ private void SetValueUnknown(string key, StringValues value) Unknown[key] = value; } + [MethodImpl(MethodImplOptions.NoInlining)] + private bool AddValueUnknown(string key, StringValues value) + { + ValidateHeaderNameCharacters(key); + Unknown.Add(key, value); + // Return true, above will throw and exit for false + return true; + } + public partial struct Enumerator : IEnumerator> { private readonly HttpResponseHeaders _collection; diff --git a/src/Servers/Kestrel/Core/src/Internal/Http/HttpResponseTrailers.cs b/src/Servers/Kestrel/Core/src/Internal/Http/HttpResponseTrailers.cs index 0a6e78bfea33..ec4144cc8319 100644 --- a/src/Servers/Kestrel/Core/src/Internal/Http/HttpResponseTrailers.cs +++ b/src/Servers/Kestrel/Core/src/Internal/Http/HttpResponseTrailers.cs @@ -28,6 +28,15 @@ private void SetValueUnknown(string key, StringValues value) Unknown[key] = value; } + [MethodImpl(MethodImplOptions.NoInlining)] + private bool AddValueUnknown(string key, StringValues value) + { + ValidateHeaderNameCharacters(key); + Unknown.Add(key, value); + // Return true, above will throw and exit for false + return true; + } + public partial struct Enumerator : IEnumerator> { private readonly HttpResponseTrailers _collection; diff --git a/src/Servers/Kestrel/perf/Kestrel.Performance/ResponseHeaderCollectionBenchmark.cs b/src/Servers/Kestrel/perf/Kestrel.Performance/ResponseHeaderCollectionBenchmark.cs index eb45d5cd3fb9..530a0ec968ce 100644 --- a/src/Servers/Kestrel/perf/Kestrel.Performance/ResponseHeaderCollectionBenchmark.cs +++ b/src/Servers/Kestrel/perf/Kestrel.Performance/ResponseHeaderCollectionBenchmark.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; @@ -13,12 +13,13 @@ using Microsoft.AspNetCore.Server.Kestrel.Core.Internal; using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http; using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal; +using Microsoft.Net.Http.Headers; namespace Microsoft.AspNetCore.Server.Kestrel.Performance { public class ResponseHeaderCollectionBenchmark { - private const int InnerLoopCount = 512; + private const int InnerLoopCount = 128; private static readonly byte[] _bytesServer = Encoding.ASCII.GetBytes("\r\nServer: Kestrel"); private static readonly DateHeaderValueManager _dateHeaderValueManager = new DateHeaderValueManager(); @@ -84,7 +85,7 @@ private void ContentLengthString(int count) { _responseHeadersDirect.Reset(); - _response.Headers["Content-Length"] = "0"; + _response.Headers[HeaderNames.ContentLength] = "0"; } } @@ -118,21 +119,21 @@ private void Common(int count) var headers = _response.Headers; - headers["Connection"] = "Close"; - headers["Cache-Control"] = "public, max-age=30672000"; - headers["Vary"] = "Accept-Encoding"; - headers["Content-Encoding"] = "gzip"; - headers["Expires"] = "Fri, 12 Jan 2018 22:01:55 GMT"; - headers["Last-Modified"] = "Wed, 22 Jun 2016 20:08:29 GMT"; - headers["Set-Cookie"] = "prov=20629ccd-8b0f-e8ef-2935-cd26609fc0bc; __qca=P0-1591065732-1479167353442; _ga=GA1.2.1298898376.1479167354; _gat=1; sgt=id=9519gfde_3347_4762_8762_df51458c8ec2; acct=t=why-is-%e0%a5%a7%e0%a5%a8%e0%a5%a9-numeric&s=why-is-%e0%a5%a7%e0%a5%a8%e0%a5%a9-numeric"; - headers["ETag"] = "\"54ef7954-1078\""; - headers["Transfer-Encoding"] = "chunked"; - headers["Content-Language"] = "en-gb"; - headers["Upgrade"] = "websocket"; - headers["Via"] = "1.1 varnish"; - headers["Access-Control-Allow-Origin"] = "*"; - headers["Access-Control-Allow-credentials"] = "true"; - headers["Access-Control-Expose-Headers"] = "Client-Protocol, Content-Length, Content-Type, X-Bandwidth-Est, X-Bandwidth-Est2, X-Bandwidth-Est-Comp, X-Bandwidth-Avg, X-Walltime-Ms, X-Sequence-Num"; + headers[HeaderNames.Connection] = "Close"; + headers[HeaderNames.CacheControl] = "public, max-age=30672000"; + headers[HeaderNames.Vary] = "Accept-Encoding"; + headers[HeaderNames.ContentEncoding] = "gzip"; + headers[HeaderNames.Expires] = "Fri, 12 Jan 2018 22:01:55 GMT"; + headers[HeaderNames.LastModified] = "Wed, 22 Jun 2016 20:08:29 GMT"; + headers[HeaderNames.SetCookie] = "prov=20629ccd-8b0f-e8ef-2935-cd26609fc0bc; __qca=P0-1591065732-1479167353442; _ga=GA1.2.1298898376.1479167354; _gat=1; sgt=id=9519gfde_3347_4762_8762_df51458c8ec2; acct=t=why-is-%e0%a5%a7%e0%a5%a8%e0%a5%a9-numeric&s=why-is-%e0%a5%a7%e0%a5%a8%e0%a5%a9-numeric"; + headers[HeaderNames.ETag] = "\"54ef7954-1078\""; + headers[HeaderNames.TransferEncoding] = "chunked"; + headers[HeaderNames.ContentLanguage] = "en-gb"; + headers[HeaderNames.Upgrade] = "websocket"; + headers[HeaderNames.Via] = "1.1 varnish"; + headers[HeaderNames.AccessControlAllowOrigin] = "*"; + headers[HeaderNames.AccessControlAllowCredentials] = "true"; + headers[HeaderNames.AccessControlExposeHeaders] = "Client-Protocol, Content-Length, Content-Type, X-Bandwidth-Est, X-Bandwidth-Est2, X-Bandwidth-Est-Comp, X-Bandwidth-Avg, X-Walltime-Ms, X-Sequence-Num"; var dateHeaderValues = _dateHeaderValueManager.GetDateHeaderValues(); _responseHeadersDirect.SetRawDate(dateHeaderValues.String, dateHeaderValues.Bytes); @@ -159,8 +160,8 @@ private void Unknown(int count) headers["X-Content-Type-Options"] = "nosniff"; headers["X-Xss-Protection"] = "1; mode=block"; headers["X-Frame-Options"] = "SAMEORIGIN"; - headers["Strict-Transport-Security"] = "max-age=31536000; includeSubDomains; preload"; - headers["Content-Security-Policy"] = "default-src 'none'; script-src 'self' cdnjs.cloudflare.com code.jquery.com scotthelme.disqus.com a.disquscdn.com www.google-analytics.com go.disqus.com platform.twitter.com cdn.syndication.twimg.com; style-src 'self' a.disquscdn.com fonts.googleapis.com cdnjs.cloudflare.com platform.twitter.com; img-src 'self' data: www.gravatar.com www.google-analytics.com links.services.disqus.com referrer.disqus.com a.disquscdn.com cdn.syndication.twimg.com syndication.twitter.com pbs.twimg.com platform.twitter.com abs.twimg.com; child-src fusiontables.googleusercontent.com fusiontables.google.com www.google.com disqus.com www.youtube.com syndication.twitter.com platform.twitter.com; frame-src fusiontables.googleusercontent.com fusiontables.google.com www.google.com disqus.com www.youtube.com syndication.twitter.com platform.twitter.com; connect-src 'self' links.services.disqus.com; font-src 'self' cdnjs.cloudflare.com fonts.gstatic.com fonts.googleapis.com; form-action 'self'; upgrade-insecure-requests;"; + headers[HeaderNames.StrictTransportSecurity] = "max-age=31536000; includeSubDomains; preload"; + headers[HeaderNames.ContentSecurityPolicy] = "default-src 'none'; script-src 'self' cdnjs.cloudflare.com code.jquery.com scotthelme.disqus.com a.disquscdn.com www.google-analytics.com go.disqus.com platform.twitter.com cdn.syndication.twimg.com; style-src 'self' a.disquscdn.com fonts.googleapis.com cdnjs.cloudflare.com platform.twitter.com; img-src 'self' data: www.gravatar.com www.google-analytics.com links.services.disqus.com referrer.disqus.com a.disquscdn.com cdn.syndication.twimg.com syndication.twitter.com pbs.twimg.com platform.twitter.com abs.twimg.com; child-src fusiontables.googleusercontent.com fusiontables.google.com www.google.com disqus.com www.youtube.com syndication.twitter.com platform.twitter.com; frame-src fusiontables.googleusercontent.com fusiontables.google.com www.google.com disqus.com www.youtube.com syndication.twitter.com platform.twitter.com; connect-src 'self' links.services.disqus.com; font-src 'self' cdnjs.cloudflare.com fonts.gstatic.com fonts.googleapis.com; form-action 'self'; upgrade-insecure-requests;"; var dateHeaderValues = _dateHeaderValueManager.GetDateHeaderValues(); _responseHeadersDirect.SetRawDate(dateHeaderValues.String, dateHeaderValues.Bytes); diff --git a/src/Servers/Kestrel/perf/Kestrel.Performance/ResponseHeadersWritingBenchmark.cs b/src/Servers/Kestrel/perf/Kestrel.Performance/ResponseHeadersWritingBenchmark.cs index 987a609d45af..72c1d1268e0f 100644 --- a/src/Servers/Kestrel/perf/Kestrel.Performance/ResponseHeadersWritingBenchmark.cs +++ b/src/Servers/Kestrel/perf/Kestrel.Performance/ResponseHeadersWritingBenchmark.cs @@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http; using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure; +using Microsoft.Net.Http.Headers; namespace Microsoft.AspNetCore.Server.Kestrel.Performance { @@ -82,7 +83,7 @@ private void LiveAspNet() var responseHeaders = _responseHeaders; responseHeaders.HeaderContentEncoding = "gzip"; responseHeaders.HeaderContentType = "text/html; charset=utf-8"; - _responseHeadersDict["Strict-Transport-Security"] = "max-age=31536000; includeSubdomains"; + _responseHeadersDict[HeaderNames.StrictTransportSecurity] = "max-age=31536000; includeSubdomains"; responseHeaders.HeaderVary = "Accept-Encoding"; _responseHeadersDict["X-Powered-By"] = "ASP.NET"; diff --git a/src/Servers/Kestrel/shared/KnownHeaders.cs b/src/Servers/Kestrel/shared/KnownHeaders.cs index 0899143bc54a..acc03a08c12d 100644 --- a/src/Servers/Kestrel/shared/KnownHeaders.cs +++ b/src/Servers/Kestrel/shared/KnownHeaders.cs @@ -94,7 +94,11 @@ static KnownHeaders() "Translate", "User-Agent", "DNT", - "Upgrade-Insecure-Requests" + "Upgrade-Insecure-Requests", + "Request-Id", + "Correlation-Context", + "TraceParent", + "TraceState" }) .Concat(corsRequestHeaders) .Select((header, index) => new KnownHeader @@ -539,21 +543,21 @@ public static string GeneratedFile() new { Headers = requestHeaders, - HeadersByLength = requestHeaders.GroupBy(x => x.Name.Length), + HeadersByLength = requestHeaders.OrderBy(x => x.Name.Length).GroupBy(x => x.Name.Length), ClassName = "HttpRequestHeaders", Bytes = default(byte[]) }, new { Headers = responseHeaders, - HeadersByLength = responseHeaders.GroupBy(x => x.Name.Length), + HeadersByLength = responseHeaders.OrderBy(x => x.Name.Length).GroupBy(x => x.Name.Length), ClassName = "HttpResponseHeaders", Bytes = responseHeaders.SelectMany(header => header.Bytes).ToArray() }, new { Headers = responseTrailers, - HeadersByLength = responseTrailers.GroupBy(x => x.Name.Length), + HeadersByLength = responseTrailers.OrderBy(x => x.Name.Length).GroupBy(x => x.Name.Length), ClassName = "HttpResponseTrailers", Bytes = responseTrailers.SelectMany(header => header.Bytes).ToArray() } @@ -647,27 +651,43 @@ protected override bool TryGetValueFast(string key, out StringValues value) switch (key.Length) {{{Each(loop.HeadersByLength, byLength => $@" case {byLength.Key}: - {{{Each(byLength, header => $@" - if (""{header.Name}"".Equals(key, StringComparison.OrdinalIgnoreCase)) - {{{(header.Identifier == "ContentLength" ? @" - if (_contentLength.HasValue) - { - value = HeaderUtilities.FormatNonNegativeInt64(_contentLength.Value); - return true; - } - return false;" : $@" - if ({header.TestBit()}) - {{ - value = _headers._{header.Identifier}; - return true; - }} - return false;")} - }}")} - }} - break;")} + {{{Each(byLength.OrderBy(h => !h.PrimaryHeader), header => $@" + if (ReferenceEquals(HeaderNames.{header.Identifier}, key)) + {{{(header.Identifier == "ContentLength" ? @" + if (_contentLength.HasValue) + { + value = HeaderUtilities.FormatNonNegativeInt64(_contentLength.Value); + return true; + } + return false;" : $@" + if ({header.TestBit()}) + {{ + value = _headers._{header.Identifier}; + return true; + }} + return false;")} + }}")} +{Each(byLength.OrderBy(h => !h.PrimaryHeader), header => $@" + if (HeaderNames.{header.Identifier}.Equals(key, StringComparison.OrdinalIgnoreCase)) + {{{(header.Identifier == "ContentLength" ? @" + if (_contentLength.HasValue) + { + value = HeaderUtilities.FormatNonNegativeInt64(_contentLength.Value); + return true; + } + return false;" : $@" + if ({header.TestBit()}) + {{ + value = _headers._{header.Identifier}; + return true; + }} + return false;")} + }}")} + break; + }}")} }} - return MaybeUnknown?.TryGetValue(key, out value) ?? false; + return TryGetUnknown(key, ref value); }} protected override void SetValueFast(string key, StringValues value) @@ -676,17 +696,26 @@ protected override void SetValueFast(string key, StringValues value) switch (key.Length) {{{Each(loop.HeadersByLength, byLength => $@" case {byLength.Key}: - {{{Each(byLength, header => $@" - if (""{header.Name}"".Equals(key, StringComparison.OrdinalIgnoreCase)) - {{{(header.Identifier == "ContentLength" ? $@" - _contentLength = ParseContentLength(value.ToString());" : $@" - {header.SetBit()}; - _headers._{header.Identifier} = value;{(header.EnhancedSetter == false ? "" : $@" - _headers._raw{header.Identifier} = null;")}")} - return; - }}")} - }} - break;")} + {{{Each(byLength.OrderBy(h => !h.PrimaryHeader), header => $@" + if (ReferenceEquals(HeaderNames.{header.Identifier}, key)) + {{{(header.Identifier == "ContentLength" ? $@" + _contentLength = ParseContentLength(value.ToString());" : $@" + {header.SetBit()}; + _headers._{header.Identifier} = value;{(header.EnhancedSetter == false ? "" : $@" + _headers._raw{header.Identifier} = null;")}")} + return; + }}")} +{Each(byLength.OrderBy(h => !h.PrimaryHeader), header => $@" + if (HeaderNames.{header.Identifier}.Equals(key, StringComparison.OrdinalIgnoreCase)) + {{{(header.Identifier == "ContentLength" ? $@" + _contentLength = ParseContentLength(value.ToString());" : $@" + {header.SetBit()}; + _headers._{header.Identifier} = value;{(header.EnhancedSetter == false ? "" : $@" + _headers._raw{header.Identifier} = null;")}")} + return; + }}")} + break; + }}")} }} SetValueUnknown(key, value); @@ -698,32 +727,47 @@ protected override bool AddValueFast(string key, StringValues value) switch (key.Length) {{{Each(loop.HeadersByLength, byLength => $@" case {byLength.Key}: - {{{Each(byLength, header => $@" - if (""{header.Name}"".Equals(key, StringComparison.OrdinalIgnoreCase)) - {{{(header.Identifier == "ContentLength" ? $@" - if (!_contentLength.HasValue) - {{ - _contentLength = ParseContentLength(value); - return true; - }} - return false;" : $@" - if ({header.TestNotBit()}) - {{ - {header.SetBit()}; - _headers._{header.Identifier} = value;{(header.EnhancedSetter == false ? "" : $@" - _headers._raw{header.Identifier} = null;")} - return true; - }} - return false;")} - }}")} - }} - break;")} + {{{Each(byLength.OrderBy(h => !h.PrimaryHeader), header => $@" + if (ReferenceEquals(HeaderNames.{header.Identifier}, key)) + {{{(header.Identifier == "ContentLength" ? $@" + if (!_contentLength.HasValue) + {{ + _contentLength = ParseContentLength(value); + return true; + }} + return false;" : $@" + if ({header.TestNotBit()}) + {{ + {header.SetBit()}; + _headers._{header.Identifier} = value;{(header.EnhancedSetter == false ? "" : $@" + _headers._raw{header.Identifier} = null;")} + return true; + }} + return false;")} + }}")} + {Each(byLength.OrderBy(h => !h.PrimaryHeader), header => $@" + if (HeaderNames.{header.Identifier}.Equals(key, StringComparison.OrdinalIgnoreCase)) + {{{(header.Identifier == "ContentLength" ? $@" + if (!_contentLength.HasValue) + {{ + _contentLength = ParseContentLength(value); + return true; + }} + return false;" : $@" + if ({header.TestNotBit()}) + {{ + {header.SetBit()}; + _headers._{header.Identifier} = value;{(header.EnhancedSetter == false ? "" : $@" + _headers._raw{header.Identifier} = null;")} + return true; + }} + return false;")} + }}")} + break; + }}")} }} -{(loop.ClassName == "HttpResponseHeaders" ? @" - ValidateHeaderNameCharacters(key);" : "")} - Unknown.Add(key, value); - // Return true, above will throw and exit for false - return true; + + return AddValueUnknown(key, value); }} protected override bool RemoveFast(string key) @@ -731,29 +775,47 @@ protected override bool RemoveFast(string key) switch (key.Length) {{{Each(loop.HeadersByLength, byLength => $@" case {byLength.Key}: - {{{Each(byLength, header => $@" - if (""{header.Name}"".Equals(key, StringComparison.OrdinalIgnoreCase)) - {{{(header.Identifier == "ContentLength" ? @" - if (_contentLength.HasValue) - { - _contentLength = null; - return true; - } - return false;" : $@" - if ({header.TestBit()}) - {{ - {header.ClearBit()}; - _headers._{header.Identifier} = default(StringValues);{(header.EnhancedSetter == false ? "" : $@" - _headers._raw{header.Identifier} = null;")} - return true; - }} - return false;")} - }}")} - }} - break;")} + {{{Each(byLength.OrderBy(h => !h.PrimaryHeader), header => $@" + if (ReferenceEquals(HeaderNames.{header.Identifier}, key)) + {{{(header.Identifier == "ContentLength" ? @" + if (_contentLength.HasValue) + { + _contentLength = null; + return true; + } + return false;" : $@" + if ({header.TestBit()}) + {{ + {header.ClearBit()}; + _headers._{header.Identifier} = default(StringValues);{(header.EnhancedSetter == false ? "" : $@" + _headers._raw{header.Identifier} = null;")} + return true; + }} + return false;")} + }}")} + {Each(byLength.OrderBy(h => !h.PrimaryHeader), header => $@" + if (HeaderNames.{header.Identifier}.Equals(key, StringComparison.OrdinalIgnoreCase)) + {{{(header.Identifier == "ContentLength" ? @" + if (_contentLength.HasValue) + { + _contentLength = null; + return true; + } + return false;" : $@" + if ({header.TestBit()}) + {{ + {header.ClearBit()}; + _headers._{header.Identifier} = default(StringValues);{(header.EnhancedSetter == false ? "" : $@" + _headers._raw{header.Identifier} = null;")} + return true; + }} + return false;")} + }}")} + break; + }}")} }} - return MaybeUnknown?.Remove(key) ?? false; + return RemoveUnknown(key); }} {(loop.ClassName != "HttpRequestHeaders" ? $@" protected override void ClearFast() @@ -770,7 +832,7 @@ protected override bool RemoveFast(string key) {Each(loop.Headers.Where(header => header.Identifier != "ContentLength").OrderBy(h => !h.PrimaryHeader), header => $@" if ({header.TestTempBit()}) {{ - _headers._{header.Identifier} = default(StringValues); + _headers._{header.Identifier} = default; if({header.TestNotTempBit()}) {{ return; @@ -786,7 +848,7 @@ protected override bool RemoveFast(string key) {Each(loop.Headers.Where(header => header.Identifier != "ContentLength").OrderBy(h => !h.PrimaryHeader), header => $@" if ({header.TestTempBit()}) {{ - _headers._{header.Identifier} = default(StringValues); + _headers._{header.Identifier} = default; if({header.TestNotTempBit()}) {{ return; @@ -809,7 +871,7 @@ protected override bool CopyToFast(KeyValuePair[] array, i {{ return false; }} - array[arrayIndex] = new KeyValuePair(""{header.Name}"", _headers._{header.Identifier}); + array[arrayIndex] = new KeyValuePair(HeaderNames.{header.Identifier}, _headers._{header.Identifier}); ++arrayIndex; }}")} if (_contentLength.HasValue) @@ -818,7 +880,7 @@ protected override bool CopyToFast(KeyValuePair[] array, i {{ return false; }} - array[arrayIndex] = new KeyValuePair(""Content-Length"", HeaderUtilities.FormatNonNegativeInt64(_contentLength.Value)); + array[arrayIndex] = new KeyValuePair(HeaderNames.ContentLength, HeaderUtilities.FormatNonNegativeInt64(_contentLength.Value)); ++arrayIndex; }} ((ICollection>)MaybeUnknown)?.CopyTo(array, arrayIndex); @@ -970,14 +1032,14 @@ public bool MoveNext() Header{header.Identifier}: // case {header.Index} if ({header.TestBit()}) {{ - _current = new KeyValuePair(""{header.Name}"", _collection._headers._{header.Identifier}); + _current = new KeyValuePair(HeaderNames.{header.Identifier}, _collection._headers._{header.Identifier}); _next = {header.Index + 1}; return true; }}")} {(!loop.ClassName.Contains("Trailers") ? $@"HeaderContentLength: // case {loop.Headers.Count() - 1} if (_collection._contentLength.HasValue) {{ - _current = new KeyValuePair(""Content-Length"", HeaderUtilities.FormatNonNegativeInt64(_collection._contentLength.Value)); + _current = new KeyValuePair(HeaderNames.ContentLength, HeaderUtilities.FormatNonNegativeInt64(_collection._contentLength.Value)); _next = {loop.Headers.Count()}; return true; }}" : "")} diff --git a/src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2StreamTests.cs b/src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2StreamTests.cs index a67a5a7128ae..83d1a264e00b 100644 --- a/src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2StreamTests.cs +++ b/src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2StreamTests.cs @@ -273,8 +273,8 @@ await ExpectAsync(Http2FrameType.DATA, } [Theory] - [InlineData(HeaderNames.Path, "/")] - [InlineData(HeaderNames.Scheme, "http")] + [InlineData(":path", "/")] + [InlineData(":scheme", "http")] public async Task HEADERS_Received_CONNECTMethod_WithSchemeOrPath_Reset(string headerName, string value) { await InitializeConnectionAsync(_noopApplication); diff --git a/src/SignalR/common/Http.Connections/src/Internal/Transports/ServerSentEventsTransport.cs b/src/SignalR/common/Http.Connections/src/Internal/Transports/ServerSentEventsTransport.cs index 1c0dd85719c0..69253ea11bad 100644 --- a/src/SignalR/common/Http.Connections/src/Internal/Transports/ServerSentEventsTransport.cs +++ b/src/SignalR/common/Http.Connections/src/Internal/Transports/ServerSentEventsTransport.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Http.Features; using Microsoft.Extensions.Logging; +using Microsoft.Net.Http.Headers; namespace Microsoft.AspNetCore.Http.Connections.Internal.Transports { @@ -26,13 +27,13 @@ public ServerSentEventsTransport(PipeReader application, string connectionId, IL public async Task ProcessRequestAsync(HttpContext context, CancellationToken token) { context.Response.ContentType = "text/event-stream"; - context.Response.Headers["Cache-Control"] = "no-cache"; + context.Response.Headers[HeaderNames.CacheControl] = "no-cache"; // Make sure we disable all response buffering for SSE var bufferingFeature = context.Features.Get(); bufferingFeature?.DisableResponseBuffering(); - context.Response.Headers["Content-Encoding"] = "identity"; + context.Response.Headers[HeaderNames.ContentEncoding] = "identity"; // Workaround for a Firefox bug where EventSource won't fire the open event // until it receives some data