From f09696445822c2d0c6337735ccb8a2f57ba29d0a Mon Sep 17 00:00:00 2001 From: Ben Adams Date: Tue, 29 Dec 2015 15:59:57 +0000 Subject: [PATCH] Known headers have known offsets Also has "Faster output header handling" #528 in it :-/ --- .../Http/Frame.cs | 23 +- .../Http/FrameHeaders.Generated.cs | 3006 +++++++++-------- .../Http/FrameResponseHeaders.cs | 13 +- .../MemoryPoolIterator2.Generated.cs | 338 ++ .../Infrastructure/MemoryPoolIterator2.cs | 2 +- .../project.json | 2 +- .../KnownHeaders.cs | 308 +- .../Program.cs | 21 + .../project.json | 2 + 9 files changed, 2184 insertions(+), 1531 deletions(-) create mode 100644 src/Microsoft.AspNet.Server.Kestrel/Infrastructure/MemoryPoolIterator2.Generated.cs diff --git a/src/Microsoft.AspNet.Server.Kestrel/Http/Frame.cs b/src/Microsoft.AspNet.Server.Kestrel/Http/Frame.cs index 8b6dd828a..9bff28a51 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Http/Frame.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Http/Frame.cs @@ -640,14 +640,13 @@ private Task CreateResponseHeader( { var begin = SocketOutput.ProducingStart(); var end = begin; - if (_keepAlive) + if (_keepAlive && _responseHeaders.HasConnection) { - foreach (var connectionValue in _responseHeaders.HeaderConnection) + var connection = _responseHeaders.HeaderConnection.ToString(); + + if (connection.IndexOf("close", StringComparison.OrdinalIgnoreCase) != -1) { - if (connectionValue.IndexOf("close", StringComparison.OrdinalIgnoreCase) != -1) - { - _keepAlive = false; - } + _keepAlive = false; } } @@ -834,6 +833,7 @@ private bool RequestUrlStartsWithPathBase(string requestUrl, out bool caseMatche public static bool TakeMessageHeaders(SocketInput input, FrameRequestHeaders requestHeaders) { + MemoryPoolIterator2 endName; var scan = input.ConsumingStart(); var consumed = scan; try @@ -843,8 +843,15 @@ public static bool TakeMessageHeaders(SocketInput input, FrameRequestHeaders req while (!scan.IsEnd) { var beginName = scan; - scan.Seek(ref _vectorColons, ref _vectorCRs); - var endName = scan; + if (scan.Peek() == '\r' || scan.SeekCommonHeader()) + { + endName = scan; + } + else + { + scan.Seek(ref _vectorColons, ref _vectorCRs); + endName = scan; + } chFirst = scan.Take(); var beginValue = scan; diff --git a/src/Microsoft.AspNet.Server.Kestrel/Http/FrameHeaders.Generated.cs b/src/Microsoft.AspNet.Server.Kestrel/Http/FrameHeaders.Generated.cs index d0a5561d1..95e272d92 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Http/FrameHeaders.Generated.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Http/FrameHeaders.Generated.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; -using System.Text; using Microsoft.AspNet.Server.Kestrel.Infrastructure; using Microsoft.Extensions.Primitives; @@ -59,6 +58,7 @@ public partial class FrameRequestHeaders private StringValues _AccessControlRequestHeaders; + public StringValues HeaderCacheControl { get @@ -772,77 +772,13 @@ protected override StringValues GetValueFast(string key) { switch (key.Length) { - case 13: - { - if ("Cache-Control".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if (((_bits & 1L) != 0)) - { - return _CacheControl; - } - else - { - throw new System.Collections.Generic.KeyNotFoundException(); - } - } - - if ("Content-Range".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if (((_bits & 131072L) != 0)) - { - return _ContentRange; - } - else - { - throw new System.Collections.Generic.KeyNotFoundException(); - } - } - - if ("Last-Modified".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if (((_bits & 524288L) != 0)) - { - return _LastModified; - } - else - { - throw new System.Collections.Generic.KeyNotFoundException(); - } - } - - if ("Authorization".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if (((_bits & 16777216L) != 0)) - { - return _Authorization; - } - else - { - throw new System.Collections.Generic.KeyNotFoundException(); - } - } - - if ("If-None-Match".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if (((_bits & 2147483648L) != 0)) - { - return _IfNoneMatch; - } - else - { - throw new System.Collections.Generic.KeyNotFoundException(); - } - } - } - break; - - case 10: + case 4: { - if ("Connection".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Host".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 2L) != 0)) + if (((_bits & 268435456L) != 0)) { - return _Connection; + return _Host; } else { @@ -850,11 +786,11 @@ protected override StringValues GetValueFast(string key) } } - if ("Keep-Alive".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("From".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 8L) != 0)) + if (((_bits & 134217728L) != 0)) { - return _KeepAlive; + return _From; } else { @@ -862,11 +798,11 @@ protected override StringValues GetValueFast(string key) } } - if ("User-Agent".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Date".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 1099511627776L) != 0)) + if (((_bits & 4L) != 0)) { - return _UserAgent; + return _Date; } else { @@ -876,25 +812,13 @@ protected override StringValues GetValueFast(string key) } break; - case 4: + case 5: { - if ("Date".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if (((_bits & 4L) != 0)) - { - return _Date; - } - else - { - throw new System.Collections.Generic.KeyNotFoundException(); - } - } - - if ("From".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Range".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 134217728L) != 0)) + if (((_bits & 137438953472L) != 0)) { - return _From; + return _Range; } else { @@ -902,11 +826,11 @@ protected override StringValues GetValueFast(string key) } } - if ("Host".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Allow".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 268435456L) != 0)) + if (((_bits & 1024L) != 0)) { - return _Host; + return _Allow; } else { @@ -930,11 +854,11 @@ protected override StringValues GetValueFast(string key) } } - if ("Accept".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Origin".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 1048576L) != 0)) + if (((_bits & 2199023255552L) != 0)) { - return _Accept; + return _Origin; } else { @@ -942,11 +866,11 @@ protected override StringValues GetValueFast(string key) } } - if ("Cookie".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Expect".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 33554432L) != 0)) + if (((_bits & 67108864L) != 0)) { - return _Cookie; + return _Expect; } else { @@ -954,11 +878,11 @@ protected override StringValues GetValueFast(string key) } } - if ("Expect".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Cookie".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 67108864L) != 0)) + if (((_bits & 33554432L) != 0)) { - return _Expect; + return _Cookie; } else { @@ -966,11 +890,11 @@ protected override StringValues GetValueFast(string key) } } - if ("Origin".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Accept".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 2199023255552L) != 0)) + if (((_bits & 1048576L) != 0)) { - return _Origin; + return _Accept; } else { @@ -982,11 +906,11 @@ protected override StringValues GetValueFast(string key) case 7: { - if ("Trailer".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Warning".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 32L) != 0)) + if (((_bits & 512L) != 0)) { - return _Trailer; + return _Warning; } else { @@ -1006,11 +930,11 @@ protected override StringValues GetValueFast(string key) } } - if ("Warning".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Trailer".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 512L) != 0)) + if (((_bits & 32L) != 0)) { - return _Warning; + return _Trailer; } else { @@ -1018,11 +942,11 @@ protected override StringValues GetValueFast(string key) } } - if ("Expires".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Referer".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 262144L) != 0)) + if (((_bits & 68719476736L) != 0)) { - return _Expires; + return _Referer; } else { @@ -1030,11 +954,11 @@ protected override StringValues GetValueFast(string key) } } - if ("Referer".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Expires".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 68719476736L) != 0)) + if (((_bits & 262144L) != 0)) { - return _Referer; + return _Expires; } else { @@ -1044,13 +968,13 @@ protected override StringValues GetValueFast(string key) } break; - case 17: + case 8: { - if ("Transfer-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("If-Range".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 64L) != 0)) + if (((_bits & 4294967296L) != 0)) { - return _TransferEncoding; + return _IfRange; } else { @@ -1058,11 +982,11 @@ protected override StringValues GetValueFast(string key) } } - if ("If-Modified-Since".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("If-Match".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 1073741824L) != 0)) + if (((_bits & 536870912L) != 0)) { - return _IfModifiedSince; + return _IfMatch; } else { @@ -1072,13 +996,13 @@ protected override StringValues GetValueFast(string key) } break; - case 3: + case 9: { - if ("Via".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Translate".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 256L) != 0)) + if (((_bits & 549755813888L) != 0)) { - return _Via; + return _Translate; } else { @@ -1088,13 +1012,13 @@ protected override StringValues GetValueFast(string key) } break; - case 5: + case 10: { - if ("Allow".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("User-Agent".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 1024L) != 0)) + if (((_bits & 1099511627776L) != 0)) { - return _Allow; + return _UserAgent; } else { @@ -1102,39 +1026,39 @@ protected override StringValues GetValueFast(string key) } } - if ("Range".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Keep-Alive".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 137438953472L) != 0)) + if (((_bits & 8L) != 0)) { - return _Range; + return _KeepAlive; } else { throw new System.Collections.Generic.KeyNotFoundException(); } } - } - break; - - case 14: - { - if ("Content-Length".Equals(key, StringComparison.OrdinalIgnoreCase)) + + if ("Connection".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 2048L) != 0)) + if (((_bits & 2L) != 0)) { - return _ContentLength; + return _Connection; } else { throw new System.Collections.Generic.KeyNotFoundException(); } } - - if ("Accept-Charset".Equals(key, StringComparison.OrdinalIgnoreCase)) + } + break; + + case 11: + { + if ("Content-MD5".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 2097152L) != 0)) + if (((_bits & 65536L) != 0)) { - return _AcceptCharset; + return _ContentMD5; } else { @@ -1146,11 +1070,11 @@ protected override StringValues GetValueFast(string key) case 12: { - if ("Content-Type".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Max-Forwards".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 4096L) != 0)) + if (((_bits & 17179869184L) != 0)) { - return _ContentType; + return _MaxForwards; } else { @@ -1158,11 +1082,11 @@ protected override StringValues GetValueFast(string key) } } - if ("Max-Forwards".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Content-Type".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 17179869184L) != 0)) + if (((_bits & 4096L) != 0)) { - return _MaxForwards; + return _ContentType; } else { @@ -1172,13 +1096,13 @@ protected override StringValues GetValueFast(string key) } break; - case 16: + case 13: { - if ("Content-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Last-Modified".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 8192L) != 0)) + if (((_bits & 524288L) != 0)) { - return _ContentEncoding; + return _LastModified; } else { @@ -1186,11 +1110,11 @@ protected override StringValues GetValueFast(string key) } } - if ("Content-Language".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("If-None-Match".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 16384L) != 0)) + if (((_bits & 2147483648L) != 0)) { - return _ContentLanguage; + return _IfNoneMatch; } else { @@ -1198,27 +1122,35 @@ protected override StringValues GetValueFast(string key) } } - if ("Content-Location".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Content-Range".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 32768L) != 0)) + if (((_bits & 131072L) != 0)) { - return _ContentLocation; + return _ContentRange; } else { throw new System.Collections.Generic.KeyNotFoundException(); } } - } - break; - - case 11: - { - if ("Content-MD5".Equals(key, StringComparison.OrdinalIgnoreCase)) + + if ("Cache-Control".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 65536L) != 0)) + if (((_bits & 1L) != 0)) { - return _ContentMD5; + return _CacheControl; + } + else + { + throw new System.Collections.Generic.KeyNotFoundException(); + } + } + + if ("Authorization".Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if (((_bits & 16777216L) != 0)) + { + return _Authorization; } else { @@ -1228,13 +1160,13 @@ protected override StringValues GetValueFast(string key) } break; - case 15: + case 14: { - if ("Accept-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Content-Length".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 4194304L) != 0)) + if (((_bits & 2048L) != 0)) { - return _AcceptEncoding; + return _ContentLength; } else { @@ -1242,6 +1174,22 @@ protected override StringValues GetValueFast(string key) } } + if ("Accept-Charset".Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if (((_bits & 2097152L) != 0)) + { + return _AcceptCharset; + } + else + { + throw new System.Collections.Generic.KeyNotFoundException(); + } + } + } + break; + + case 15: + { if ("Accept-Language".Equals(key, StringComparison.OrdinalIgnoreCase)) { if (((_bits & 8388608L) != 0)) @@ -1253,16 +1201,28 @@ protected override StringValues GetValueFast(string key) throw new System.Collections.Generic.KeyNotFoundException(); } } + + if ("Accept-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if (((_bits & 4194304L) != 0)) + { + return _AcceptEncoding; + } + else + { + throw new System.Collections.Generic.KeyNotFoundException(); + } + } } break; - case 8: + case 16: { - if ("If-Match".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Content-Location".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 536870912L) != 0)) + if (((_bits & 32768L) != 0)) { - return _IfMatch; + return _ContentLocation; } else { @@ -1270,11 +1230,23 @@ protected override StringValues GetValueFast(string key) } } - if ("If-Range".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Content-Language".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 4294967296L) != 0)) + if (((_bits & 16384L) != 0)) { - return _IfRange; + return _ContentLanguage; + } + else + { + throw new System.Collections.Generic.KeyNotFoundException(); + } + } + + if ("Content-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if (((_bits & 8192L) != 0)) + { + return _ContentEncoding; } else { @@ -1284,13 +1256,13 @@ protected override StringValues GetValueFast(string key) } break; - case 19: + case 17: { - if ("If-Unmodified-Since".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Transfer-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 8589934592L) != 0)) + if (((_bits & 64L) != 0)) { - return _IfUnmodifiedSince; + return _TransferEncoding; } else { @@ -1298,6 +1270,22 @@ protected override StringValues GetValueFast(string key) } } + if ("If-Modified-Since".Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if (((_bits & 1073741824L) != 0)) + { + return _IfModifiedSince; + } + else + { + throw new System.Collections.Generic.KeyNotFoundException(); + } + } + } + break; + + case 19: + { if ("Proxy-Authorization".Equals(key, StringComparison.OrdinalIgnoreCase)) { if (((_bits & 34359738368L) != 0)) @@ -1309,6 +1297,18 @@ protected override StringValues GetValueFast(string key) throw new System.Collections.Generic.KeyNotFoundException(); } } + + if ("If-Unmodified-Since".Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if (((_bits & 8589934592L) != 0)) + { + return _IfUnmodifiedSince; + } + else + { + throw new System.Collections.Generic.KeyNotFoundException(); + } + } } break; @@ -1328,13 +1328,13 @@ protected override StringValues GetValueFast(string key) } break; - case 9: + case 3: { - if ("Translate".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Via".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 549755813888L) != 0)) + if (((_bits & 256L) != 0)) { - return _Translate; + return _Via; } else { @@ -1386,13 +1386,13 @@ protected override bool TryGetValueFast(string key, out StringValues value) { switch (key.Length) { - case 13: + case 4: { - if ("Cache-Control".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Host".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 1L) != 0)) + if (((_bits & 268435456L) != 0)) { - value = _CacheControl; + value = _Host; return true; } else @@ -1402,11 +1402,11 @@ protected override bool TryGetValueFast(string key, out StringValues value) } } - if ("Content-Range".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("From".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 131072L) != 0)) + if (((_bits & 134217728L) != 0)) { - value = _ContentRange; + value = _From; return true; } else @@ -1416,11 +1416,11 @@ protected override bool TryGetValueFast(string key, out StringValues value) } } - if ("Last-Modified".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Date".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 524288L) != 0)) + if (((_bits & 4L) != 0)) { - value = _LastModified; + value = _Date; return true; } else @@ -1429,12 +1429,16 @@ protected override bool TryGetValueFast(string key, out StringValues value) return false; } } - - if ("Authorization".Equals(key, StringComparison.OrdinalIgnoreCase)) + } + break; + + case 5: + { + if ("Range".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 16777216L) != 0)) + if (((_bits & 137438953472L) != 0)) { - value = _Authorization; + value = _Range; return true; } else @@ -1444,11 +1448,11 @@ protected override bool TryGetValueFast(string key, out StringValues value) } } - if ("If-None-Match".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Allow".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 2147483648L) != 0)) + if (((_bits & 1024L) != 0)) { - value = _IfNoneMatch; + value = _Allow; return true; } else @@ -1460,13 +1464,13 @@ protected override bool TryGetValueFast(string key, out StringValues value) } break; - case 10: + case 6: { - if ("Connection".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Pragma".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 2L) != 0)) + if (((_bits & 16L) != 0)) { - value = _Connection; + value = _Pragma; return true; } else @@ -1476,11 +1480,11 @@ protected override bool TryGetValueFast(string key, out StringValues value) } } - if ("Keep-Alive".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Origin".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 8L) != 0)) + if (((_bits & 2199023255552L) != 0)) { - value = _KeepAlive; + value = _Origin; return true; } else @@ -1490,29 +1494,11 @@ protected override bool TryGetValueFast(string key, out StringValues value) } } - if ("User-Agent".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if (((_bits & 1099511627776L) != 0)) - { - value = _UserAgent; - return true; - } - else - { - value = StringValues.Empty; - return false; - } - } - } - break; - - case 4: - { - if ("Date".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Expect".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 4L) != 0)) + if (((_bits & 67108864L) != 0)) { - value = _Date; + value = _Expect; return true; } else @@ -1522,11 +1508,11 @@ protected override bool TryGetValueFast(string key, out StringValues value) } } - if ("From".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Cookie".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 134217728L) != 0)) + if (((_bits & 33554432L) != 0)) { - value = _From; + value = _Cookie; return true; } else @@ -1536,11 +1522,11 @@ protected override bool TryGetValueFast(string key, out StringValues value) } } - if ("Host".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Accept".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 268435456L) != 0)) + if (((_bits & 1048576L) != 0)) { - value = _Host; + value = _Accept; return true; } else @@ -1552,13 +1538,13 @@ protected override bool TryGetValueFast(string key, out StringValues value) } break; - case 6: + case 7: { - if ("Pragma".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Warning".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 16L) != 0)) + if (((_bits & 512L) != 0)) { - value = _Pragma; + value = _Warning; return true; } else @@ -1568,11 +1554,11 @@ protected override bool TryGetValueFast(string key, out StringValues value) } } - if ("Accept".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Upgrade".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 1048576L) != 0)) + if (((_bits & 128L) != 0)) { - value = _Accept; + value = _Upgrade; return true; } else @@ -1582,11 +1568,11 @@ protected override bool TryGetValueFast(string key, out StringValues value) } } - if ("Cookie".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Trailer".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 33554432L) != 0)) + if (((_bits & 32L) != 0)) { - value = _Cookie; + value = _Trailer; return true; } else @@ -1596,11 +1582,11 @@ protected override bool TryGetValueFast(string key, out StringValues value) } } - if ("Expect".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Referer".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 67108864L) != 0)) + if (((_bits & 68719476736L) != 0)) { - value = _Expect; + value = _Referer; return true; } else @@ -1610,11 +1596,11 @@ protected override bool TryGetValueFast(string key, out StringValues value) } } - if ("Origin".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Expires".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 2199023255552L) != 0)) + if (((_bits & 262144L) != 0)) { - value = _Origin; + value = _Expires; return true; } else @@ -1626,13 +1612,13 @@ protected override bool TryGetValueFast(string key, out StringValues value) } break; - case 7: + case 8: { - if ("Trailer".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("If-Range".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 32L) != 0)) + if (((_bits & 4294967296L) != 0)) { - value = _Trailer; + value = _IfRange; return true; } else @@ -1642,11 +1628,11 @@ protected override bool TryGetValueFast(string key, out StringValues value) } } - if ("Upgrade".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("If-Match".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 128L) != 0)) + if (((_bits & 536870912L) != 0)) { - value = _Upgrade; + value = _IfMatch; return true; } else @@ -1655,12 +1641,16 @@ protected override bool TryGetValueFast(string key, out StringValues value) return false; } } - - if ("Warning".Equals(key, StringComparison.OrdinalIgnoreCase)) + } + break; + + case 9: + { + if ("Translate".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 512L) != 0)) + if (((_bits & 549755813888L) != 0)) { - value = _Warning; + value = _Translate; return true; } else @@ -1669,12 +1659,16 @@ protected override bool TryGetValueFast(string key, out StringValues value) return false; } } - - if ("Expires".Equals(key, StringComparison.OrdinalIgnoreCase)) + } + break; + + case 10: + { + if ("User-Agent".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 262144L) != 0)) + if (((_bits & 1099511627776L) != 0)) { - value = _Expires; + value = _UserAgent; return true; } else @@ -1684,29 +1678,11 @@ protected override bool TryGetValueFast(string key, out StringValues value) } } - if ("Referer".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if (((_bits & 68719476736L) != 0)) - { - value = _Referer; - return true; - } - else - { - value = StringValues.Empty; - return false; - } - } - } - break; - - case 17: - { - if ("Transfer-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Keep-Alive".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 64L) != 0)) + if (((_bits & 8L) != 0)) { - value = _TransferEncoding; + value = _KeepAlive; return true; } else @@ -1716,11 +1692,11 @@ protected override bool TryGetValueFast(string key, out StringValues value) } } - if ("If-Modified-Since".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Connection".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 1073741824L) != 0)) + if (((_bits & 2L) != 0)) { - value = _IfModifiedSince; + value = _Connection; return true; } else @@ -1732,13 +1708,13 @@ protected override bool TryGetValueFast(string key, out StringValues value) } break; - case 3: + case 11: { - if ("Via".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Content-MD5".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 256L) != 0)) + if (((_bits & 65536L) != 0)) { - value = _Via; + value = _ContentMD5; return true; } else @@ -1750,13 +1726,13 @@ protected override bool TryGetValueFast(string key, out StringValues value) } break; - case 5: + case 12: { - if ("Allow".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Max-Forwards".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 1024L) != 0)) + if (((_bits & 17179869184L) != 0)) { - value = _Allow; + value = _MaxForwards; return true; } else @@ -1766,11 +1742,11 @@ protected override bool TryGetValueFast(string key, out StringValues value) } } - if ("Range".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Content-Type".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 137438953472L) != 0)) + if (((_bits & 4096L) != 0)) { - value = _Range; + value = _ContentType; return true; } else @@ -1782,13 +1758,13 @@ protected override bool TryGetValueFast(string key, out StringValues value) } break; - case 14: + case 13: { - if ("Content-Length".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Last-Modified".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 2048L) != 0)) + if (((_bits & 524288L) != 0)) { - value = _ContentLength; + value = _LastModified; return true; } else @@ -1798,11 +1774,11 @@ protected override bool TryGetValueFast(string key, out StringValues value) } } - if ("Accept-Charset".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("If-None-Match".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 2097152L) != 0)) + if (((_bits & 2147483648L) != 0)) { - value = _AcceptCharset; + value = _IfNoneMatch; return true; } else @@ -1811,16 +1787,12 @@ protected override bool TryGetValueFast(string key, out StringValues value) return false; } } - } - break; - - case 12: - { - if ("Content-Type".Equals(key, StringComparison.OrdinalIgnoreCase)) + + if ("Content-Range".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 4096L) != 0)) + if (((_bits & 131072L) != 0)) { - value = _ContentType; + value = _ContentRange; return true; } else @@ -1830,11 +1802,25 @@ protected override bool TryGetValueFast(string key, out StringValues value) } } - if ("Max-Forwards".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Cache-Control".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 17179869184L) != 0)) + if (((_bits & 1L) != 0)) { - value = _MaxForwards; + value = _CacheControl; + return true; + } + else + { + value = StringValues.Empty; + return false; + } + } + + if ("Authorization".Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if (((_bits & 16777216L) != 0)) + { + value = _Authorization; return true; } else @@ -1846,13 +1832,13 @@ protected override bool TryGetValueFast(string key, out StringValues value) } break; - case 16: + case 14: { - if ("Content-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Content-Length".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 8192L) != 0)) + if (((_bits & 2048L) != 0)) { - value = _ContentEncoding; + value = _ContentLength; return true; } else @@ -1862,11 +1848,29 @@ protected override bool TryGetValueFast(string key, out StringValues value) } } - if ("Content-Language".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Accept-Charset".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 16384L) != 0)) + if (((_bits & 2097152L) != 0)) { - value = _ContentLanguage; + value = _AcceptCharset; + return true; + } + else + { + value = StringValues.Empty; + return false; + } + } + } + break; + + case 15: + { + if ("Accept-Language".Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if (((_bits & 8388608L) != 0)) + { + value = _AcceptLanguage; return true; } else @@ -1876,11 +1880,11 @@ protected override bool TryGetValueFast(string key, out StringValues value) } } - if ("Content-Location".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Accept-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 32768L) != 0)) + if (((_bits & 4194304L) != 0)) { - value = _ContentLocation; + value = _AcceptEncoding; return true; } else @@ -1892,13 +1896,13 @@ protected override bool TryGetValueFast(string key, out StringValues value) } break; - case 11: + case 16: { - if ("Content-MD5".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Content-Location".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 65536L) != 0)) + if (((_bits & 32768L) != 0)) { - value = _ContentMD5; + value = _ContentLocation; return true; } else @@ -1907,16 +1911,12 @@ protected override bool TryGetValueFast(string key, out StringValues value) return false; } } - } - break; - - case 15: - { - if ("Accept-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) + + if ("Content-Language".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 4194304L) != 0)) + if (((_bits & 16384L) != 0)) { - value = _AcceptEncoding; + value = _ContentLanguage; return true; } else @@ -1926,11 +1926,11 @@ protected override bool TryGetValueFast(string key, out StringValues value) } } - if ("Accept-Language".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Content-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 8388608L) != 0)) + if (((_bits & 8192L) != 0)) { - value = _AcceptLanguage; + value = _ContentEncoding; return true; } else @@ -1942,13 +1942,13 @@ protected override bool TryGetValueFast(string key, out StringValues value) } break; - case 8: + case 17: { - if ("If-Match".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Transfer-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 536870912L) != 0)) + if (((_bits & 64L) != 0)) { - value = _IfMatch; + value = _TransferEncoding; return true; } else @@ -1958,11 +1958,11 @@ protected override bool TryGetValueFast(string key, out StringValues value) } } - if ("If-Range".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("If-Modified-Since".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 4294967296L) != 0)) + if (((_bits & 1073741824L) != 0)) { - value = _IfRange; + value = _IfModifiedSince; return true; } else @@ -1976,11 +1976,11 @@ protected override bool TryGetValueFast(string key, out StringValues value) case 19: { - if ("If-Unmodified-Since".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Proxy-Authorization".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 8589934592L) != 0)) + if (((_bits & 34359738368L) != 0)) { - value = _IfUnmodifiedSince; + value = _ProxyAuthorization; return true; } else @@ -1990,11 +1990,11 @@ protected override bool TryGetValueFast(string key, out StringValues value) } } - if ("Proxy-Authorization".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("If-Unmodified-Since".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 34359738368L) != 0)) + if (((_bits & 8589934592L) != 0)) { - value = _ProxyAuthorization; + value = _IfUnmodifiedSince; return true; } else @@ -2024,13 +2024,13 @@ protected override bool TryGetValueFast(string key, out StringValues value) } break; - case 9: + case 3: { - if ("Translate".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Via".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 549755813888L) != 0)) + if (((_bits & 256L) != 0)) { - value = _Translate; + value = _Via; return true; } else @@ -2085,215 +2085,244 @@ protected override void SetValueFast(string key, StringValues value) { switch (key.Length) { - case 13: + case 4: { - if ("Cache-Control".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Host".Equals(key, StringComparison.OrdinalIgnoreCase)) { - _bits |= 1L; - _CacheControl = value; + _bits |= 268435456L; + _Host = value; return; } - if ("Content-Range".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("From".Equals(key, StringComparison.OrdinalIgnoreCase)) { - _bits |= 131072L; - _ContentRange = value; + _bits |= 134217728L; + _From = value; return; } - if ("Last-Modified".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Date".Equals(key, StringComparison.OrdinalIgnoreCase)) { - _bits |= 524288L; - _LastModified = value; + _bits |= 4L; + _Date = value; return; } - - if ("Authorization".Equals(key, StringComparison.OrdinalIgnoreCase)) + } + break; + + case 5: + { + if ("Range".Equals(key, StringComparison.OrdinalIgnoreCase)) { - _bits |= 16777216L; - _Authorization = value; + _bits |= 137438953472L; + _Range = value; return; } - if ("If-None-Match".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Allow".Equals(key, StringComparison.OrdinalIgnoreCase)) { - _bits |= 2147483648L; - _IfNoneMatch = value; + _bits |= 1024L; + _Allow = value; return; } } break; - case 10: + case 6: { - if ("Connection".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Pragma".Equals(key, StringComparison.OrdinalIgnoreCase)) { - _bits |= 2L; - _Connection = value; + _bits |= 16L; + _Pragma = value; return; } - if ("Keep-Alive".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Origin".Equals(key, StringComparison.OrdinalIgnoreCase)) { - _bits |= 8L; - _KeepAlive = value; + _bits |= 2199023255552L; + _Origin = value; return; } - if ("User-Agent".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - _bits |= 1099511627776L; - _UserAgent = value; - return; - } - } - break; - - case 4: - { - if ("Date".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Expect".Equals(key, StringComparison.OrdinalIgnoreCase)) { - _bits |= 4L; - _Date = value; + _bits |= 67108864L; + _Expect = value; return; } - if ("From".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Cookie".Equals(key, StringComparison.OrdinalIgnoreCase)) { - _bits |= 134217728L; - _From = value; + _bits |= 33554432L; + _Cookie = value; return; } - if ("Host".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Accept".Equals(key, StringComparison.OrdinalIgnoreCase)) { - _bits |= 268435456L; - _Host = value; + _bits |= 1048576L; + _Accept = value; return; } } break; - case 6: + case 7: { - if ("Pragma".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Warning".Equals(key, StringComparison.OrdinalIgnoreCase)) { - _bits |= 16L; - _Pragma = value; + _bits |= 512L; + _Warning = value; return; } - if ("Accept".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Upgrade".Equals(key, StringComparison.OrdinalIgnoreCase)) { - _bits |= 1048576L; - _Accept = value; + _bits |= 128L; + _Upgrade = value; return; } - if ("Cookie".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Trailer".Equals(key, StringComparison.OrdinalIgnoreCase)) { - _bits |= 33554432L; - _Cookie = value; + _bits |= 32L; + _Trailer = value; return; } - if ("Expect".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Referer".Equals(key, StringComparison.OrdinalIgnoreCase)) { - _bits |= 67108864L; - _Expect = value; + _bits |= 68719476736L; + _Referer = value; return; } - if ("Origin".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Expires".Equals(key, StringComparison.OrdinalIgnoreCase)) { - _bits |= 2199023255552L; - _Origin = value; + _bits |= 262144L; + _Expires = value; return; } } break; - case 7: + case 8: { - if ("Trailer".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("If-Range".Equals(key, StringComparison.OrdinalIgnoreCase)) { - _bits |= 32L; - _Trailer = value; + _bits |= 4294967296L; + _IfRange = value; return; } - if ("Upgrade".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("If-Match".Equals(key, StringComparison.OrdinalIgnoreCase)) { - _bits |= 128L; - _Upgrade = value; + _bits |= 536870912L; + _IfMatch = value; return; } - - if ("Warning".Equals(key, StringComparison.OrdinalIgnoreCase)) + } + break; + + case 9: + { + if ("Translate".Equals(key, StringComparison.OrdinalIgnoreCase)) { - _bits |= 512L; - _Warning = value; + _bits |= 549755813888L; + _Translate = value; + return; + } + } + break; + + case 10: + { + if ("User-Agent".Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 1099511627776L; + _UserAgent = value; return; } - if ("Expires".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Keep-Alive".Equals(key, StringComparison.OrdinalIgnoreCase)) { - _bits |= 262144L; - _Expires = value; + _bits |= 8L; + _KeepAlive = value; return; } - if ("Referer".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Connection".Equals(key, StringComparison.OrdinalIgnoreCase)) { - _bits |= 68719476736L; - _Referer = value; + _bits |= 2L; + _Connection = value; return; } } break; - case 17: + case 11: { - if ("Transfer-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - _bits |= 64L; - _TransferEncoding = value; - return; - } - - if ("If-Modified-Since".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Content-MD5".Equals(key, StringComparison.OrdinalIgnoreCase)) { - _bits |= 1073741824L; - _IfModifiedSince = value; + _bits |= 65536L; + _ContentMD5 = value; return; } } break; - case 3: + case 12: { - if ("Via".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Max-Forwards".Equals(key, StringComparison.OrdinalIgnoreCase)) { - _bits |= 256L; - _Via = value; + _bits |= 17179869184L; + _MaxForwards = value; + return; + } + + if ("Content-Type".Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 4096L; + _ContentType = value; return; } } break; - case 5: + case 13: { - if ("Allow".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Last-Modified".Equals(key, StringComparison.OrdinalIgnoreCase)) { - _bits |= 1024L; - _Allow = value; + _bits |= 524288L; + _LastModified = value; return; } - if ("Range".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("If-None-Match".Equals(key, StringComparison.OrdinalIgnoreCase)) { - _bits |= 137438953472L; - _Range = value; + _bits |= 2147483648L; + _IfNoneMatch = value; + return; + } + + if ("Content-Range".Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 131072L; + _ContentRange = value; + return; + } + + if ("Cache-Control".Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 1L; + _CacheControl = value; + return; + } + + if ("Authorization".Equals(key, StringComparison.OrdinalIgnoreCase)) + { + _bits |= 16777216L; + _Authorization = value; return; } } @@ -2317,19 +2346,19 @@ protected override void SetValueFast(string key, StringValues value) } break; - case 12: + case 15: { - if ("Content-Type".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Accept-Language".Equals(key, StringComparison.OrdinalIgnoreCase)) { - _bits |= 4096L; - _ContentType = value; + _bits |= 8388608L; + _AcceptLanguage = value; return; } - if ("Max-Forwards".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Accept-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) { - _bits |= 17179869184L; - _MaxForwards = value; + _bits |= 4194304L; + _AcceptEncoding = value; return; } } @@ -2337,10 +2366,10 @@ protected override void SetValueFast(string key, StringValues value) case 16: { - if ("Content-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Content-Location".Equals(key, StringComparison.OrdinalIgnoreCase)) { - _bits |= 8192L; - _ContentEncoding = value; + _bits |= 32768L; + _ContentLocation = value; return; } @@ -2351,77 +2380,48 @@ protected override void SetValueFast(string key, StringValues value) return; } - if ("Content-Location".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - _bits |= 32768L; - _ContentLocation = value; - return; - } - } - break; - - case 11: - { - if ("Content-MD5".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Content-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) { - _bits |= 65536L; - _ContentMD5 = value; + _bits |= 8192L; + _ContentEncoding = value; return; } } break; - case 15: + case 17: { - if ("Accept-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Transfer-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) { - _bits |= 4194304L; - _AcceptEncoding = value; + _bits |= 64L; + _TransferEncoding = value; return; } - if ("Accept-Language".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("If-Modified-Since".Equals(key, StringComparison.OrdinalIgnoreCase)) { - _bits |= 8388608L; - _AcceptLanguage = value; + _bits |= 1073741824L; + _IfModifiedSince = value; return; } } break; - case 8: + case 19: { - if ("If-Match".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Proxy-Authorization".Equals(key, StringComparison.OrdinalIgnoreCase)) { - _bits |= 536870912L; - _IfMatch = value; + _bits |= 34359738368L; + _ProxyAuthorization = value; return; } - if ("If-Range".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - _bits |= 4294967296L; - _IfRange = value; - return; - } - } - break; - - case 19: - { if ("If-Unmodified-Since".Equals(key, StringComparison.OrdinalIgnoreCase)) { _bits |= 8589934592L; _IfUnmodifiedSince = value; return; } - - if ("Proxy-Authorization".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - _bits |= 34359738368L; - _ProxyAuthorization = value; - return; - } } break; @@ -2436,12 +2436,12 @@ protected override void SetValueFast(string key, StringValues value) } break; - case 9: + case 3: { - if ("Translate".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Via".Equals(key, StringComparison.OrdinalIgnoreCase)) { - _bits |= 549755813888L; - _Translate = value; + _bits |= 256L; + _Via = value; return; } } @@ -2475,104 +2475,30 @@ protected override void AddValueFast(string key, StringValues value) { switch (key.Length) { - case 13: - { - if ("Cache-Control".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if (((_bits & 1L) != 0)) - { - throw new ArgumentException("An item with the same key has already been added."); - } - _bits |= 1L; - _CacheControl = value; - return; - } - - if ("Content-Range".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if (((_bits & 131072L) != 0)) - { - throw new ArgumentException("An item with the same key has already been added."); - } - _bits |= 131072L; - _ContentRange = value; - return; - } - - if ("Last-Modified".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if (((_bits & 524288L) != 0)) - { - throw new ArgumentException("An item with the same key has already been added."); - } - _bits |= 524288L; - _LastModified = value; - return; - } - - if ("Authorization".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if (((_bits & 16777216L) != 0)) - { - throw new ArgumentException("An item with the same key has already been added."); - } - _bits |= 16777216L; - _Authorization = value; - return; - } - - if ("If-None-Match".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if (((_bits & 2147483648L) != 0)) - { - throw new ArgumentException("An item with the same key has already been added."); - } - _bits |= 2147483648L; - _IfNoneMatch = value; - return; - } - } - break; - - case 10: + case 4: { - if ("Connection".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Host".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 2L) != 0)) + if (((_bits & 268435456L) != 0)) { throw new ArgumentException("An item with the same key has already been added."); } - _bits |= 2L; - _Connection = value; + _bits |= 268435456L; + _Host = value; return; } - if ("Keep-Alive".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("From".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 8L) != 0)) + if (((_bits & 134217728L) != 0)) { throw new ArgumentException("An item with the same key has already been added."); } - _bits |= 8L; - _KeepAlive = value; + _bits |= 134217728L; + _From = value; return; } - if ("User-Agent".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if (((_bits & 1099511627776L) != 0)) - { - throw new ArgumentException("An item with the same key has already been added."); - } - _bits |= 1099511627776L; - _UserAgent = value; - return; - } - } - break; - - case 4: - { if ("Date".Equals(key, StringComparison.OrdinalIgnoreCase)) { if (((_bits & 4L) != 0)) @@ -2583,26 +2509,30 @@ protected override void AddValueFast(string key, StringValues value) _Date = value; return; } - - if ("From".Equals(key, StringComparison.OrdinalIgnoreCase)) + } + break; + + case 5: + { + if ("Range".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 134217728L) != 0)) + if (((_bits & 137438953472L) != 0)) { throw new ArgumentException("An item with the same key has already been added."); } - _bits |= 134217728L; - _From = value; + _bits |= 137438953472L; + _Range = value; return; } - if ("Host".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Allow".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 268435456L) != 0)) + if (((_bits & 1024L) != 0)) { throw new ArgumentException("An item with the same key has already been added."); } - _bits |= 268435456L; - _Host = value; + _bits |= 1024L; + _Allow = value; return; } } @@ -2616,30 +2546,19 @@ protected override void AddValueFast(string key, StringValues value) { throw new ArgumentException("An item with the same key has already been added."); } - _bits |= 16L; - _Pragma = value; - return; - } - - if ("Accept".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if (((_bits & 1048576L) != 0)) - { - throw new ArgumentException("An item with the same key has already been added."); - } - _bits |= 1048576L; - _Accept = value; + _bits |= 16L; + _Pragma = value; return; } - if ("Cookie".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Origin".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 33554432L) != 0)) + if (((_bits & 2199023255552L) != 0)) { throw new ArgumentException("An item with the same key has already been added."); } - _bits |= 33554432L; - _Cookie = value; + _bits |= 2199023255552L; + _Origin = value; return; } @@ -2654,14 +2573,25 @@ protected override void AddValueFast(string key, StringValues value) return; } - if ("Origin".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Cookie".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 2199023255552L) != 0)) + if (((_bits & 33554432L) != 0)) { throw new ArgumentException("An item with the same key has already been added."); } - _bits |= 2199023255552L; - _Origin = value; + _bits |= 33554432L; + _Cookie = value; + return; + } + + if ("Accept".Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if (((_bits & 1048576L) != 0)) + { + throw new ArgumentException("An item with the same key has already been added."); + } + _bits |= 1048576L; + _Accept = value; return; } } @@ -2669,14 +2599,14 @@ protected override void AddValueFast(string key, StringValues value) case 7: { - if ("Trailer".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Warning".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 32L) != 0)) + if (((_bits & 512L) != 0)) { throw new ArgumentException("An item with the same key has already been added."); } - _bits |= 32L; - _Trailer = value; + _bits |= 512L; + _Warning = value; return; } @@ -2691,129 +2621,129 @@ protected override void AddValueFast(string key, StringValues value) return; } - if ("Warning".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Trailer".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 512L) != 0)) + if (((_bits & 32L) != 0)) { throw new ArgumentException("An item with the same key has already been added."); } - _bits |= 512L; - _Warning = value; + _bits |= 32L; + _Trailer = value; return; } - if ("Expires".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Referer".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 262144L) != 0)) + if (((_bits & 68719476736L) != 0)) { throw new ArgumentException("An item with the same key has already been added."); } - _bits |= 262144L; - _Expires = value; + _bits |= 68719476736L; + _Referer = value; return; } - if ("Referer".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Expires".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 68719476736L) != 0)) + if (((_bits & 262144L) != 0)) { throw new ArgumentException("An item with the same key has already been added."); } - _bits |= 68719476736L; - _Referer = value; + _bits |= 262144L; + _Expires = value; return; } } break; - case 17: + case 8: { - if ("Transfer-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("If-Range".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 64L) != 0)) + if (((_bits & 4294967296L) != 0)) { throw new ArgumentException("An item with the same key has already been added."); } - _bits |= 64L; - _TransferEncoding = value; + _bits |= 4294967296L; + _IfRange = value; return; } - if ("If-Modified-Since".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("If-Match".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 1073741824L) != 0)) + if (((_bits & 536870912L) != 0)) { throw new ArgumentException("An item with the same key has already been added."); } - _bits |= 1073741824L; - _IfModifiedSince = value; + _bits |= 536870912L; + _IfMatch = value; return; } } break; - case 3: + case 9: { - if ("Via".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Translate".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 256L) != 0)) + if (((_bits & 549755813888L) != 0)) { throw new ArgumentException("An item with the same key has already been added."); } - _bits |= 256L; - _Via = value; + _bits |= 549755813888L; + _Translate = value; return; } } break; - case 5: + case 10: { - if ("Allow".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("User-Agent".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 1024L) != 0)) + if (((_bits & 1099511627776L) != 0)) { throw new ArgumentException("An item with the same key has already been added."); } - _bits |= 1024L; - _Allow = value; + _bits |= 1099511627776L; + _UserAgent = value; return; } - if ("Range".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Keep-Alive".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 137438953472L) != 0)) + if (((_bits & 8L) != 0)) { throw new ArgumentException("An item with the same key has already been added."); } - _bits |= 137438953472L; - _Range = value; + _bits |= 8L; + _KeepAlive = value; return; } - } - break; - - case 14: - { - if ("Content-Length".Equals(key, StringComparison.OrdinalIgnoreCase)) + + if ("Connection".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 2048L) != 0)) + if (((_bits & 2L) != 0)) { throw new ArgumentException("An item with the same key has already been added."); } - _bits |= 2048L; - _ContentLength = value; + _bits |= 2L; + _Connection = value; return; } - - if ("Accept-Charset".Equals(key, StringComparison.OrdinalIgnoreCase)) + } + break; + + case 11: + { + if ("Content-MD5".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 2097152L) != 0)) + if (((_bits & 65536L) != 0)) { throw new ArgumentException("An item with the same key has already been added."); } - _bits |= 2097152L; - _AcceptCharset = value; + _bits |= 65536L; + _ContentMD5 = value; return; } } @@ -2821,77 +2751,110 @@ protected override void AddValueFast(string key, StringValues value) case 12: { - if ("Content-Type".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Max-Forwards".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 4096L) != 0)) + if (((_bits & 17179869184L) != 0)) { throw new ArgumentException("An item with the same key has already been added."); } - _bits |= 4096L; - _ContentType = value; + _bits |= 17179869184L; + _MaxForwards = value; return; } - if ("Max-Forwards".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Content-Type".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 17179869184L) != 0)) + if (((_bits & 4096L) != 0)) { throw new ArgumentException("An item with the same key has already been added."); } - _bits |= 17179869184L; - _MaxForwards = value; + _bits |= 4096L; + _ContentType = value; return; } } break; - case 16: + case 13: { - if ("Content-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Last-Modified".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 8192L) != 0)) + if (((_bits & 524288L) != 0)) { throw new ArgumentException("An item with the same key has already been added."); } - _bits |= 8192L; - _ContentEncoding = value; + _bits |= 524288L; + _LastModified = value; return; } - if ("Content-Language".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("If-None-Match".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 16384L) != 0)) + if (((_bits & 2147483648L) != 0)) { throw new ArgumentException("An item with the same key has already been added."); } - _bits |= 16384L; - _ContentLanguage = value; + _bits |= 2147483648L; + _IfNoneMatch = value; return; } - if ("Content-Location".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Content-Range".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 32768L) != 0)) + if (((_bits & 131072L) != 0)) { throw new ArgumentException("An item with the same key has already been added."); } - _bits |= 32768L; - _ContentLocation = value; + _bits |= 131072L; + _ContentRange = value; + return; + } + + if ("Cache-Control".Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if (((_bits & 1L) != 0)) + { + throw new ArgumentException("An item with the same key has already been added."); + } + _bits |= 1L; + _CacheControl = value; + return; + } + + if ("Authorization".Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if (((_bits & 16777216L) != 0)) + { + throw new ArgumentException("An item with the same key has already been added."); + } + _bits |= 16777216L; + _Authorization = value; return; } } break; - case 11: + case 14: { - if ("Content-MD5".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Content-Length".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 65536L) != 0)) + if (((_bits & 2048L) != 0)) { throw new ArgumentException("An item with the same key has already been added."); } - _bits |= 65536L; - _ContentMD5 = value; + _bits |= 2048L; + _ContentLength = value; + return; + } + + if ("Accept-Charset".Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if (((_bits & 2097152L) != 0)) + { + throw new ArgumentException("An item with the same key has already been added."); + } + _bits |= 2097152L; + _AcceptCharset = value; return; } } @@ -2899,6 +2862,17 @@ protected override void AddValueFast(string key, StringValues value) case 15: { + if ("Accept-Language".Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if (((_bits & 8388608L) != 0)) + { + throw new ArgumentException("An item with the same key has already been added."); + } + _bits |= 8388608L; + _AcceptLanguage = value; + return; + } + if ("Accept-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) { if (((_bits & 4194304L) != 0)) @@ -2909,41 +2883,67 @@ protected override void AddValueFast(string key, StringValues value) _AcceptEncoding = value; return; } + } + break; + + case 16: + { + if ("Content-Location".Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if (((_bits & 32768L) != 0)) + { + throw new ArgumentException("An item with the same key has already been added."); + } + _bits |= 32768L; + _ContentLocation = value; + return; + } + + if ("Content-Language".Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if (((_bits & 16384L) != 0)) + { + throw new ArgumentException("An item with the same key has already been added."); + } + _bits |= 16384L; + _ContentLanguage = value; + return; + } - if ("Accept-Language".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Content-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 8388608L) != 0)) + if (((_bits & 8192L) != 0)) { throw new ArgumentException("An item with the same key has already been added."); } - _bits |= 8388608L; - _AcceptLanguage = value; + _bits |= 8192L; + _ContentEncoding = value; return; } } break; - case 8: + case 17: { - if ("If-Match".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Transfer-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 536870912L) != 0)) + if (((_bits & 64L) != 0)) { throw new ArgumentException("An item with the same key has already been added."); } - _bits |= 536870912L; - _IfMatch = value; + _bits |= 64L; + _TransferEncoding = value; return; } - if ("If-Range".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("If-Modified-Since".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 4294967296L) != 0)) + if (((_bits & 1073741824L) != 0)) { throw new ArgumentException("An item with the same key has already been added."); } - _bits |= 4294967296L; - _IfRange = value; + _bits |= 1073741824L; + _IfModifiedSince = value; return; } } @@ -2951,25 +2951,25 @@ protected override void AddValueFast(string key, StringValues value) case 19: { - if ("If-Unmodified-Since".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Proxy-Authorization".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 8589934592L) != 0)) + if (((_bits & 34359738368L) != 0)) { throw new ArgumentException("An item with the same key has already been added."); } - _bits |= 8589934592L; - _IfUnmodifiedSince = value; + _bits |= 34359738368L; + _ProxyAuthorization = value; return; } - if ("Proxy-Authorization".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("If-Unmodified-Since".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 34359738368L) != 0)) + if (((_bits & 8589934592L) != 0)) { throw new ArgumentException("An item with the same key has already been added."); } - _bits |= 34359738368L; - _ProxyAuthorization = value; + _bits |= 8589934592L; + _IfUnmodifiedSince = value; return; } } @@ -2990,16 +2990,16 @@ protected override void AddValueFast(string key, StringValues value) } break; - case 9: + case 3: { - if ("Translate".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Via".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 549755813888L) != 0)) + if (((_bits & 256L) != 0)) { throw new ArgumentException("An item with the same key has already been added."); } - _bits |= 549755813888L; - _Translate = value; + _bits |= 256L; + _Via = value; return; } } @@ -3041,14 +3041,14 @@ protected override bool RemoveFast(string key) { switch (key.Length) { - case 13: + case 4: { - if ("Cache-Control".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Host".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 1L) != 0)) + if (((_bits & 268435456L) != 0)) { - _bits &= ~1L; - _CacheControl = StringValues.Empty; + _bits &= ~268435456L; + _Host = StringValues.Empty; return true; } else @@ -3057,12 +3057,12 @@ protected override bool RemoveFast(string key) } } - if ("Content-Range".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("From".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 131072L) != 0)) + if (((_bits & 134217728L) != 0)) { - _bits &= ~131072L; - _ContentRange = StringValues.Empty; + _bits &= ~134217728L; + _From = StringValues.Empty; return true; } else @@ -3071,12 +3071,12 @@ protected override bool RemoveFast(string key) } } - if ("Last-Modified".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Date".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 524288L) != 0)) + if (((_bits & 4L) != 0)) { - _bits &= ~524288L; - _LastModified = StringValues.Empty; + _bits &= ~4L; + _Date = StringValues.Empty; return true; } else @@ -3084,13 +3084,17 @@ protected override bool RemoveFast(string key) return false; } } - - if ("Authorization".Equals(key, StringComparison.OrdinalIgnoreCase)) + } + break; + + case 5: + { + if ("Range".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 16777216L) != 0)) + if (((_bits & 137438953472L) != 0)) { - _bits &= ~16777216L; - _Authorization = StringValues.Empty; + _bits &= ~137438953472L; + _Range = StringValues.Empty; return true; } else @@ -3099,12 +3103,12 @@ protected override bool RemoveFast(string key) } } - if ("If-None-Match".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Allow".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 2147483648L) != 0)) + if (((_bits & 1024L) != 0)) { - _bits &= ~2147483648L; - _IfNoneMatch = StringValues.Empty; + _bits &= ~1024L; + _Allow = StringValues.Empty; return true; } else @@ -3115,14 +3119,14 @@ protected override bool RemoveFast(string key) } break; - case 10: + case 6: { - if ("Connection".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Pragma".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 2L) != 0)) + if (((_bits & 16L) != 0)) { - _bits &= ~2L; - _Connection = StringValues.Empty; + _bits &= ~16L; + _Pragma = StringValues.Empty; return true; } else @@ -3131,12 +3135,12 @@ protected override bool RemoveFast(string key) } } - if ("Keep-Alive".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Origin".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 8L) != 0)) + if (((_bits & 2199023255552L) != 0)) { - _bits &= ~8L; - _KeepAlive = StringValues.Empty; + _bits &= ~2199023255552L; + _Origin = StringValues.Empty; return true; } else @@ -3145,12 +3149,40 @@ protected override bool RemoveFast(string key) } } - if ("User-Agent".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Expect".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 1099511627776L) != 0)) + if (((_bits & 67108864L) != 0)) { - _bits &= ~1099511627776L; - _UserAgent = StringValues.Empty; + _bits &= ~67108864L; + _Expect = StringValues.Empty; + return true; + } + else + { + return false; + } + } + + if ("Cookie".Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if (((_bits & 33554432L) != 0)) + { + _bits &= ~33554432L; + _Cookie = StringValues.Empty; + return true; + } + else + { + return false; + } + } + + if ("Accept".Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if (((_bits & 1048576L) != 0)) + { + _bits &= ~1048576L; + _Accept = StringValues.Empty; return true; } else @@ -3161,14 +3193,14 @@ protected override bool RemoveFast(string key) } break; - case 4: + case 7: { - if ("Date".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Warning".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 4L) != 0)) + if (((_bits & 512L) != 0)) { - _bits &= ~4L; - _Date = StringValues.Empty; + _bits &= ~512L; + _Warning = StringValues.Empty; return true; } else @@ -3177,12 +3209,12 @@ protected override bool RemoveFast(string key) } } - if ("From".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Upgrade".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 134217728L) != 0)) + if (((_bits & 128L) != 0)) { - _bits &= ~134217728L; - _From = StringValues.Empty; + _bits &= ~128L; + _Upgrade = StringValues.Empty; return true; } else @@ -3191,12 +3223,12 @@ protected override bool RemoveFast(string key) } } - if ("Host".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Trailer".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 268435456L) != 0)) + if (((_bits & 32L) != 0)) { - _bits &= ~268435456L; - _Host = StringValues.Empty; + _bits &= ~32L; + _Trailer = StringValues.Empty; return true; } else @@ -3204,17 +3236,13 @@ protected override bool RemoveFast(string key) return false; } } - } - break; - - case 6: - { - if ("Pragma".Equals(key, StringComparison.OrdinalIgnoreCase)) + + if ("Referer".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 16L) != 0)) + if (((_bits & 68719476736L) != 0)) { - _bits &= ~16L; - _Pragma = StringValues.Empty; + _bits &= ~68719476736L; + _Referer = StringValues.Empty; return true; } else @@ -3223,12 +3251,12 @@ protected override bool RemoveFast(string key) } } - if ("Accept".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Expires".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 1048576L) != 0)) + if (((_bits & 262144L) != 0)) { - _bits &= ~1048576L; - _Accept = StringValues.Empty; + _bits &= ~262144L; + _Expires = StringValues.Empty; return true; } else @@ -3236,13 +3264,17 @@ protected override bool RemoveFast(string key) return false; } } - - if ("Cookie".Equals(key, StringComparison.OrdinalIgnoreCase)) + } + break; + + case 8: + { + if ("If-Range".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 33554432L) != 0)) + if (((_bits & 4294967296L) != 0)) { - _bits &= ~33554432L; - _Cookie = StringValues.Empty; + _bits &= ~4294967296L; + _IfRange = StringValues.Empty; return true; } else @@ -3251,12 +3283,12 @@ protected override bool RemoveFast(string key) } } - if ("Expect".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("If-Match".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 67108864L) != 0)) + if (((_bits & 536870912L) != 0)) { - _bits &= ~67108864L; - _Expect = StringValues.Empty; + _bits &= ~536870912L; + _IfMatch = StringValues.Empty; return true; } else @@ -3264,13 +3296,17 @@ protected override bool RemoveFast(string key) return false; } } - - if ("Origin".Equals(key, StringComparison.OrdinalIgnoreCase)) + } + break; + + case 9: + { + if ("Translate".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 2199023255552L) != 0)) + if (((_bits & 549755813888L) != 0)) { - _bits &= ~2199023255552L; - _Origin = StringValues.Empty; + _bits &= ~549755813888L; + _Translate = StringValues.Empty; return true; } else @@ -3281,14 +3317,28 @@ protected override bool RemoveFast(string key) } break; - case 7: + case 10: { - if ("Trailer".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("User-Agent".Equals(key, StringComparison.OrdinalIgnoreCase)) + { + if (((_bits & 1099511627776L) != 0)) + { + _bits &= ~1099511627776L; + _UserAgent = StringValues.Empty; + return true; + } + else + { + return false; + } + } + + if ("Keep-Alive".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 32L) != 0)) + if (((_bits & 8L) != 0)) { - _bits &= ~32L; - _Trailer = StringValues.Empty; + _bits &= ~8L; + _KeepAlive = StringValues.Empty; return true; } else @@ -3297,12 +3347,12 @@ protected override bool RemoveFast(string key) } } - if ("Upgrade".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Connection".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 128L) != 0)) + if (((_bits & 2L) != 0)) { - _bits &= ~128L; - _Upgrade = StringValues.Empty; + _bits &= ~2L; + _Connection = StringValues.Empty; return true; } else @@ -3310,13 +3360,17 @@ protected override bool RemoveFast(string key) return false; } } - - if ("Warning".Equals(key, StringComparison.OrdinalIgnoreCase)) + } + break; + + case 11: + { + if ("Content-MD5".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 512L) != 0)) + if (((_bits & 65536L) != 0)) { - _bits &= ~512L; - _Warning = StringValues.Empty; + _bits &= ~65536L; + _ContentMD5 = StringValues.Empty; return true; } else @@ -3324,13 +3378,17 @@ protected override bool RemoveFast(string key) return false; } } - - if ("Expires".Equals(key, StringComparison.OrdinalIgnoreCase)) + } + break; + + case 12: + { + if ("Max-Forwards".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 262144L) != 0)) + if (((_bits & 17179869184L) != 0)) { - _bits &= ~262144L; - _Expires = StringValues.Empty; + _bits &= ~17179869184L; + _MaxForwards = StringValues.Empty; return true; } else @@ -3339,12 +3397,12 @@ protected override bool RemoveFast(string key) } } - if ("Referer".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Content-Type".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 68719476736L) != 0)) + if (((_bits & 4096L) != 0)) { - _bits &= ~68719476736L; - _Referer = StringValues.Empty; + _bits &= ~4096L; + _ContentType = StringValues.Empty; return true; } else @@ -3355,14 +3413,14 @@ protected override bool RemoveFast(string key) } break; - case 17: + case 13: { - if ("Transfer-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Last-Modified".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 64L) != 0)) + if (((_bits & 524288L) != 0)) { - _bits &= ~64L; - _TransferEncoding = StringValues.Empty; + _bits &= ~524288L; + _LastModified = StringValues.Empty; return true; } else @@ -3371,12 +3429,12 @@ protected override bool RemoveFast(string key) } } - if ("If-Modified-Since".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("If-None-Match".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 1073741824L) != 0)) + if (((_bits & 2147483648L) != 0)) { - _bits &= ~1073741824L; - _IfModifiedSince = StringValues.Empty; + _bits &= ~2147483648L; + _IfNoneMatch = StringValues.Empty; return true; } else @@ -3384,17 +3442,13 @@ protected override bool RemoveFast(string key) return false; } } - } - break; - - case 3: - { - if ("Via".Equals(key, StringComparison.OrdinalIgnoreCase)) + + if ("Content-Range".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 256L) != 0)) + if (((_bits & 131072L) != 0)) { - _bits &= ~256L; - _Via = StringValues.Empty; + _bits &= ~131072L; + _ContentRange = StringValues.Empty; return true; } else @@ -3402,17 +3456,13 @@ protected override bool RemoveFast(string key) return false; } } - } - break; - - case 5: - { - if ("Allow".Equals(key, StringComparison.OrdinalIgnoreCase)) + + if ("Cache-Control".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 1024L) != 0)) + if (((_bits & 1L) != 0)) { - _bits &= ~1024L; - _Allow = StringValues.Empty; + _bits &= ~1L; + _CacheControl = StringValues.Empty; return true; } else @@ -3421,12 +3471,12 @@ protected override bool RemoveFast(string key) } } - if ("Range".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Authorization".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 137438953472L) != 0)) + if (((_bits & 16777216L) != 0)) { - _bits &= ~137438953472L; - _Range = StringValues.Empty; + _bits &= ~16777216L; + _Authorization = StringValues.Empty; return true; } else @@ -3469,14 +3519,14 @@ protected override bool RemoveFast(string key) } break; - case 12: + case 15: { - if ("Content-Type".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Accept-Language".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 4096L) != 0)) + if (((_bits & 8388608L) != 0)) { - _bits &= ~4096L; - _ContentType = StringValues.Empty; + _bits &= ~8388608L; + _AcceptLanguage = StringValues.Empty; return true; } else @@ -3485,12 +3535,12 @@ protected override bool RemoveFast(string key) } } - if ("Max-Forwards".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Accept-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 17179869184L) != 0)) + if (((_bits & 4194304L) != 0)) { - _bits &= ~17179869184L; - _MaxForwards = StringValues.Empty; + _bits &= ~4194304L; + _AcceptEncoding = StringValues.Empty; return true; } else @@ -3503,12 +3553,12 @@ protected override bool RemoveFast(string key) case 16: { - if ("Content-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Content-Location".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 8192L) != 0)) + if (((_bits & 32768L) != 0)) { - _bits &= ~8192L; - _ContentEncoding = StringValues.Empty; + _bits &= ~32768L; + _ContentLocation = StringValues.Empty; return true; } else @@ -3531,30 +3581,12 @@ protected override bool RemoveFast(string key) } } - if ("Content-Location".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if (((_bits & 32768L) != 0)) - { - _bits &= ~32768L; - _ContentLocation = StringValues.Empty; - return true; - } - else - { - return false; - } - } - } - break; - - case 11: - { - if ("Content-MD5".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Content-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 65536L) != 0)) + if (((_bits & 8192L) != 0)) { - _bits &= ~65536L; - _ContentMD5 = StringValues.Empty; + _bits &= ~8192L; + _ContentEncoding = StringValues.Empty; return true; } else @@ -3565,14 +3597,14 @@ protected override bool RemoveFast(string key) } break; - case 15: + case 17: { - if ("Accept-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Transfer-Encoding".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 4194304L) != 0)) + if (((_bits & 64L) != 0)) { - _bits &= ~4194304L; - _AcceptEncoding = StringValues.Empty; + _bits &= ~64L; + _TransferEncoding = StringValues.Empty; return true; } else @@ -3581,12 +3613,12 @@ protected override bool RemoveFast(string key) } } - if ("Accept-Language".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("If-Modified-Since".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 8388608L) != 0)) + if (((_bits & 1073741824L) != 0)) { - _bits &= ~8388608L; - _AcceptLanguage = StringValues.Empty; + _bits &= ~1073741824L; + _IfModifiedSince = StringValues.Empty; return true; } else @@ -3597,14 +3629,14 @@ protected override bool RemoveFast(string key) } break; - case 8: + case 19: { - if ("If-Match".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Proxy-Authorization".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 536870912L) != 0)) + if (((_bits & 34359738368L) != 0)) { - _bits &= ~536870912L; - _IfMatch = StringValues.Empty; + _bits &= ~34359738368L; + _ProxyAuthorization = StringValues.Empty; return true; } else @@ -3613,24 +3645,6 @@ protected override bool RemoveFast(string key) } } - if ("If-Range".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if (((_bits & 4294967296L) != 0)) - { - _bits &= ~4294967296L; - _IfRange = StringValues.Empty; - return true; - } - else - { - return false; - } - } - } - break; - - case 19: - { if ("If-Unmodified-Since".Equals(key, StringComparison.OrdinalIgnoreCase)) { if (((_bits & 8589934592L) != 0)) @@ -3644,20 +3658,6 @@ protected override bool RemoveFast(string key) return false; } } - - if ("Proxy-Authorization".Equals(key, StringComparison.OrdinalIgnoreCase)) - { - if (((_bits & 34359738368L) != 0)) - { - _bits &= ~34359738368L; - _ProxyAuthorization = StringValues.Empty; - return true; - } - else - { - return false; - } - } } break; @@ -3679,14 +3679,14 @@ protected override bool RemoveFast(string key) } break; - case 9: + case 3: { - if ("Translate".Equals(key, StringComparison.OrdinalIgnoreCase)) + if ("Via".Equals(key, StringComparison.OrdinalIgnoreCase)) { - if (((_bits & 549755813888L) != 0)) + if (((_bits & 256L) != 0)) { - _bits &= ~549755813888L; - _Translate = StringValues.Empty; + _bits &= ~256L; + _Via = StringValues.Empty; return true; } else @@ -4245,396 +4245,446 @@ public unsafe void Append(byte[] keyBytes, int keyOffset, int keyLength, string var pUS = (ushort*)pUB; switch (keyLength) { - case 13: + case 4: { - if ((((pUL[0] & 16131893727263186911uL) == 5711458528024281411uL) && ((pUI[2] & 3755991007u) == 1330795598u) && ((pUB[12] & 223u) == 76u))) + if ((((pUI[0] & 3755991007u) == 1414745928u))) + { + if (((_bits & 268435456L) != 0)) + { + _Host = AppendValue(_Host, value); + } + else + { + _bits |= 268435456L; + _Host = new StringValues(value); + } + return; + } + + if ((((pUI[0] & 3755991007u) == 1297044038u))) + { + if (((_bits & 134217728L) != 0)) + { + _From = AppendValue(_From, value); + } + else + { + _bits |= 134217728L; + _From = new StringValues(value); + } + return; + } + + if ((((pUI[0] & 3755991007u) == 1163149636u))) { - if (((_bits & 1L) != 0)) + if (((_bits & 4L) != 0)) { - _CacheControl = AppendValue(_CacheControl, value); + _Date = AppendValue(_Date, value); } else { - _bits |= 1L; - _CacheControl = new StringValues(value); + _bits |= 4L; + _Date = new StringValues(value); } return; } - - if ((((pUL[0] & 18437701552104792031uL) == 3266321689424580419uL) && ((pUI[2] & 3755991007u) == 1196310866u) && ((pUB[12] & 223u) == 69u))) + } + break; + + case 5: + { + if ((((pUI[0] & 3755991007u) == 1196310866u) && ((pUB[4] & 223u) == 69u))) { - if (((_bits & 131072L) != 0)) + if (((_bits & 137438953472L) != 0)) { - _ContentRange = AppendValue(_ContentRange, value); + _Range = AppendValue(_Range, value); } else { - _bits |= 131072L; - _ContentRange = new StringValues(value); + _bits |= 137438953472L; + _Range = new StringValues(value); } return; } - if ((((pUL[0] & 16131858680330051551uL) == 4922237774822850892uL) && ((pUI[2] & 3755991007u) == 1162430025u) && ((pUB[12] & 223u) == 68u))) + if ((((pUI[0] & 3755991007u) == 1330400321u) && ((pUB[4] & 223u) == 87u))) { - if (((_bits & 524288L) != 0)) + if (((_bits & 1024L) != 0)) { - _LastModified = AppendValue(_LastModified, value); + _Allow = AppendValue(_Allow, value); } else { - _bits |= 524288L; - _LastModified = new StringValues(value); + _bits |= 1024L; + _Allow = new StringValues(value); } return; } - - if ((((pUL[0] & 16131858542891098079uL) == 6505821637182772545uL) && ((pUI[2] & 3755991007u) == 1330205761u) && ((pUB[12] & 223u) == 78u))) + } + break; + + case 6: + { + if ((((pUI[0] & 3755991007u) == 1195463248u) && ((pUS[2] & 57311u) == 16717u))) { - if (((_bits & 16777216L) != 0)) + if (((_bits & 16L) != 0)) { - _Authorization = AppendValue(_Authorization, value); + _Pragma = AppendValue(_Pragma, value); } else { - _bits |= 16777216L; - _Authorization = new StringValues(value); + _bits |= 16L; + _Pragma = new StringValues(value); } return; } - if ((((pUL[0] & 18437701552106889183uL) == 3262099607620765257uL) && ((pUI[2] & 3755991007u) == 1129595213u) && ((pUB[12] & 223u) == 72u))) + if ((((pUI[0] & 3755991007u) == 1195987535u) && ((pUS[2] & 57311u) == 20041u))) { - if (((_bits & 2147483648L) != 0)) + if (((_bits & 2199023255552L) != 0)) { - _IfNoneMatch = AppendValue(_IfNoneMatch, value); + _Origin = AppendValue(_Origin, value); } else { - _bits |= 2147483648L; - _IfNoneMatch = new StringValues(value); + _bits |= 2199023255552L; + _Origin = new StringValues(value); } return; } - } - break; - - case 10: - { - if ((((pUL[0] & 16131858542891098079uL) == 5283922227757993795uL) && ((pUS[4] & 57311u) == 20047u))) + + if ((((pUI[0] & 3755991007u) == 1162893381u) && ((pUS[2] & 57311u) == 21571u))) { - if (((_bits & 2L) != 0)) + if (((_bits & 67108864L) != 0)) { - _Connection = AppendValue(_Connection, value); + _Expect = AppendValue(_Expect, value); } else { - _bits |= 2L; - _Connection = new StringValues(value); + _bits |= 67108864L; + _Expect = new StringValues(value); } return; } - if ((((pUL[0] & 16131858680330051551uL) == 5281668125874799947uL) && ((pUS[4] & 57311u) == 17750u))) + if ((((pUI[0] & 3755991007u) == 1263488835u) && ((pUS[2] & 57311u) == 17737u))) { - if (((_bits & 8L) != 0)) + if (((_bits & 33554432L) != 0)) { - _KeepAlive = AppendValue(_KeepAlive, value); + _Cookie = AppendValue(_Cookie, value); } else { - _bits |= 8L; - _KeepAlive = new StringValues(value); + _bits |= 33554432L; + _Cookie = new StringValues(value); } return; } - if ((((pUL[0] & 16131858680330051551uL) == 4992030374873092949uL) && ((pUS[4] & 57311u) == 21582u))) + if ((((pUI[0] & 3755991007u) == 1162036033u) && ((pUS[2] & 57311u) == 21584u))) { - if (((_bits & 1099511627776L) != 0)) + if (((_bits & 1048576L) != 0)) { - _UserAgent = AppendValue(_UserAgent, value); + _Accept = AppendValue(_Accept, value); } else { - _bits |= 1099511627776L; - _UserAgent = new StringValues(value); + _bits |= 1048576L; + _Accept = new StringValues(value); } return; } } break; - case 4: + case 7: { - if ((((pUI[0] & 3755991007u) == 1163149636u))) + if ((((pUI[0] & 3755991007u) == 1314013527u) && ((pUS[2] & 57311u) == 20041u) && ((pUB[6] & 223u) == 71u))) { - if (((_bits & 4L) != 0)) + if (((_bits & 512L) != 0)) { - _Date = AppendValue(_Date, value); + _Warning = AppendValue(_Warning, value); } else { - _bits |= 4L; - _Date = new StringValues(value); + _bits |= 512L; + _Warning = new StringValues(value); } return; } - if ((((pUI[0] & 3755991007u) == 1297044038u))) + if ((((pUI[0] & 3755991007u) == 1380405333u) && ((pUS[2] & 57311u) == 17473u) && ((pUB[6] & 223u) == 69u))) { - if (((_bits & 134217728L) != 0)) + if (((_bits & 128L) != 0)) { - _From = AppendValue(_From, value); + _Upgrade = AppendValue(_Upgrade, value); } else { - _bits |= 134217728L; - _From = new StringValues(value); + _bits |= 128L; + _Upgrade = new StringValues(value); } return; } - if ((((pUI[0] & 3755991007u) == 1414745928u))) + if ((((pUI[0] & 3755991007u) == 1229017684u) && ((pUS[2] & 57311u) == 17740u) && ((pUB[6] & 223u) == 82u))) { - if (((_bits & 268435456L) != 0)) + if (((_bits & 32L) != 0)) { - _Host = AppendValue(_Host, value); + _Trailer = AppendValue(_Trailer, value); } else { - _bits |= 268435456L; - _Host = new StringValues(value); + _bits |= 32L; + _Trailer = new StringValues(value); } return; } - } - break; - - case 6: - { - if ((((pUI[0] & 3755991007u) == 1195463248u) && ((pUS[2] & 57311u) == 16717u))) + + if ((((pUI[0] & 3755991007u) == 1162233170u) && ((pUS[2] & 57311u) == 17746u) && ((pUB[6] & 223u) == 82u))) { - if (((_bits & 16L) != 0)) + if (((_bits & 68719476736L) != 0)) { - _Pragma = AppendValue(_Pragma, value); + _Referer = AppendValue(_Referer, value); } else { - _bits |= 16L; - _Pragma = new StringValues(value); + _bits |= 68719476736L; + _Referer = new StringValues(value); } return; } - if ((((pUI[0] & 3755991007u) == 1162036033u) && ((pUS[2] & 57311u) == 21584u))) + if ((((pUI[0] & 3755991007u) == 1230002245u) && ((pUS[2] & 57311u) == 17746u) && ((pUB[6] & 223u) == 83u))) { - if (((_bits & 1048576L) != 0)) + if (((_bits & 262144L) != 0)) { - _Accept = AppendValue(_Accept, value); + _Expires = AppendValue(_Expires, value); } else { - _bits |= 1048576L; - _Accept = new StringValues(value); + _bits |= 262144L; + _Expires = new StringValues(value); } return; } - - if ((((pUI[0] & 3755991007u) == 1263488835u) && ((pUS[2] & 57311u) == 17737u))) + } + break; + + case 8: + { + if ((((pUL[0] & 16131858542893195231uL) == 4992044754422023753uL))) { - if (((_bits & 33554432L) != 0)) + if (((_bits & 4294967296L) != 0)) { - _Cookie = AppendValue(_Cookie, value); + _IfRange = AppendValue(_IfRange, value); } else { - _bits |= 33554432L; - _Cookie = new StringValues(value); + _bits |= 4294967296L; + _IfRange = new StringValues(value); } return; } - if ((((pUI[0] & 3755991007u) == 1162893381u) && ((pUS[2] & 57311u) == 21571u))) + if ((((pUL[0] & 16131858542893195231uL) == 5207098233614845513uL))) { - if (((_bits & 67108864L) != 0)) + if (((_bits & 536870912L) != 0)) { - _Expect = AppendValue(_Expect, value); + _IfMatch = AppendValue(_IfMatch, value); } else { - _bits |= 67108864L; - _Expect = new StringValues(value); + _bits |= 536870912L; + _IfMatch = new StringValues(value); } return; } - - if ((((pUI[0] & 3755991007u) == 1195987535u) && ((pUS[2] & 57311u) == 20041u))) + } + break; + + case 9: + { + if ((((pUL[0] & 16131858542891098079uL) == 6071217693351039572uL) && ((pUB[8] & 223u) == 69u))) { - if (((_bits & 2199023255552L) != 0)) + if (((_bits & 549755813888L) != 0)) { - _Origin = AppendValue(_Origin, value); + _Translate = AppendValue(_Translate, value); } else { - _bits |= 2199023255552L; - _Origin = new StringValues(value); + _bits |= 549755813888L; + _Translate = new StringValues(value); } return; } } break; - case 7: + case 10: { - if ((((pUI[0] & 3755991007u) == 1229017684u) && ((pUS[2] & 57311u) == 17740u) && ((pUB[6] & 223u) == 82u))) + if ((((pUL[0] & 16131858680330051551uL) == 4992030374873092949uL) && ((pUS[4] & 57311u) == 21582u))) { - if (((_bits & 32L) != 0)) + if (((_bits & 1099511627776L) != 0)) { - _Trailer = AppendValue(_Trailer, value); + _UserAgent = AppendValue(_UserAgent, value); } else { - _bits |= 32L; - _Trailer = new StringValues(value); + _bits |= 1099511627776L; + _UserAgent = new StringValues(value); } return; } - if ((((pUI[0] & 3755991007u) == 1380405333u) && ((pUS[2] & 57311u) == 17473u) && ((pUB[6] & 223u) == 69u))) + if ((((pUL[0] & 16131858680330051551uL) == 5281668125874799947uL) && ((pUS[4] & 57311u) == 17750u))) { - if (((_bits & 128L) != 0)) + if (((_bits & 8L) != 0)) { - _Upgrade = AppendValue(_Upgrade, value); + _KeepAlive = AppendValue(_KeepAlive, value); } else { - _bits |= 128L; - _Upgrade = new StringValues(value); + _bits |= 8L; + _KeepAlive = new StringValues(value); } return; } - if ((((pUI[0] & 3755991007u) == 1314013527u) && ((pUS[2] & 57311u) == 20041u) && ((pUB[6] & 223u) == 71u))) + if ((((pUL[0] & 16131858542891098079uL) == 5283922227757993795uL) && ((pUS[4] & 57311u) == 20047u))) { - if (((_bits & 512L) != 0)) + if (((_bits & 2L) != 0)) { - _Warning = AppendValue(_Warning, value); + _Connection = AppendValue(_Connection, value); } else { - _bits |= 512L; - _Warning = new StringValues(value); + _bits |= 2L; + _Connection = new StringValues(value); } return; } - - if ((((pUI[0] & 3755991007u) == 1230002245u) && ((pUS[2] & 57311u) == 17746u) && ((pUB[6] & 223u) == 83u))) + } + break; + + case 11: + { + if ((((pUL[0] & 18437701552104792031uL) == 3266321689424580419uL) && ((pUS[4] & 57311u) == 17485u) && ((pUB[10] & 255u) == 53u))) + { + if (((_bits & 65536L) != 0)) + { + _ContentMD5 = AppendValue(_ContentMD5, value); + } + else + { + _bits |= 65536L; + _ContentMD5 = new StringValues(value); + } + return; + } + } + break; + + case 12: + { + if ((((pUL[0] & 16131858543427968991uL) == 6292178792217067853uL) && ((pUI[2] & 3755991007u) == 1396986433u))) { - if (((_bits & 262144L) != 0)) + if (((_bits & 17179869184L) != 0)) { - _Expires = AppendValue(_Expires, value); + _MaxForwards = AppendValue(_MaxForwards, value); } else { - _bits |= 262144L; - _Expires = new StringValues(value); + _bits |= 17179869184L; + _MaxForwards = new StringValues(value); } return; } - if ((((pUI[0] & 3755991007u) == 1162233170u) && ((pUS[2] & 57311u) == 17746u) && ((pUB[6] & 223u) == 82u))) + if ((((pUL[0] & 18437701552104792031uL) == 3266321689424580419uL) && ((pUI[2] & 3755991007u) == 1162893652u))) { - if (((_bits & 68719476736L) != 0)) + if (((_bits & 4096L) != 0)) { - _Referer = AppendValue(_Referer, value); + _ContentType = AppendValue(_ContentType, value); } else { - _bits |= 68719476736L; - _Referer = new StringValues(value); + _bits |= 4096L; + _ContentType = new StringValues(value); } return; } } break; - case 17: + case 13: { - if ((((pUL[0] & 16131858542891098079uL) == 5928221808112259668uL) && ((pUL[1] & 16131858542891098111uL) == 5641115115480565037uL) && ((pUB[16] & 223u) == 71u))) + if ((((pUL[0] & 16131858680330051551uL) == 4922237774822850892uL) && ((pUI[2] & 3755991007u) == 1162430025u) && ((pUB[12] & 223u) == 68u))) { - if (((_bits & 64L) != 0)) + if (((_bits & 524288L) != 0)) { - _TransferEncoding = AppendValue(_TransferEncoding, value); + _LastModified = AppendValue(_LastModified, value); } else { - _bits |= 64L; - _TransferEncoding = new StringValues(value); + _bits |= 524288L; + _LastModified = new StringValues(value); } return; } - if ((((pUL[0] & 16131858542893195231uL) == 5064654363342751305uL) && ((pUL[1] & 16131858543427968991uL) == 4849894470315165001uL) && ((pUB[16] & 223u) == 69u))) + if ((((pUL[0] & 18437701552106889183uL) == 3262099607620765257uL) && ((pUI[2] & 3755991007u) == 1129595213u) && ((pUB[12] & 223u) == 72u))) { - if (((_bits & 1073741824L) != 0)) + if (((_bits & 2147483648L) != 0)) { - _IfModifiedSince = AppendValue(_IfModifiedSince, value); + _IfNoneMatch = AppendValue(_IfNoneMatch, value); } else { - _bits |= 1073741824L; - _IfModifiedSince = new StringValues(value); + _bits |= 2147483648L; + _IfNoneMatch = new StringValues(value); } return; } - } - break; - - case 3: - { - if ((((pUS[0] & 57311u) == 18774u) && ((pUB[2] & 223u) == 65u))) + + if ((((pUL[0] & 18437701552104792031uL) == 3266321689424580419uL) && ((pUI[2] & 3755991007u) == 1196310866u) && ((pUB[12] & 223u) == 69u))) { - if (((_bits & 256L) != 0)) + if (((_bits & 131072L) != 0)) { - _Via = AppendValue(_Via, value); + _ContentRange = AppendValue(_ContentRange, value); } else { - _bits |= 256L; - _Via = new StringValues(value); + _bits |= 131072L; + _ContentRange = new StringValues(value); } return; } - } - break; - - case 5: - { - if ((((pUI[0] & 3755991007u) == 1330400321u) && ((pUB[4] & 223u) == 87u))) + + if ((((pUL[0] & 16131893727263186911uL) == 5711458528024281411uL) && ((pUI[2] & 3755991007u) == 1330795598u) && ((pUB[12] & 223u) == 76u))) { - if (((_bits & 1024L) != 0)) + if (((_bits & 1L) != 0)) { - _Allow = AppendValue(_Allow, value); + _CacheControl = AppendValue(_CacheControl, value); } else { - _bits |= 1024L; - _Allow = new StringValues(value); + _bits |= 1L; + _CacheControl = new StringValues(value); } return; } - if ((((pUI[0] & 3755991007u) == 1196310866u) && ((pUB[4] & 223u) == 69u))) + if ((((pUL[0] & 16131858542891098079uL) == 6505821637182772545uL) && ((pUI[2] & 3755991007u) == 1330205761u) && ((pUB[12] & 223u) == 78u))) { - if (((_bits & 137438953472L) != 0)) + if (((_bits & 16777216L) != 0)) { - _Range = AppendValue(_Range, value); + _Authorization = AppendValue(_Authorization, value); } else { - _bits |= 137438953472L; - _Range = new StringValues(value); + _bits |= 16777216L; + _Authorization = new StringValues(value); } return; } @@ -4673,32 +4723,32 @@ public unsafe void Append(byte[] keyBytes, int keyOffset, int keyLength, string } break; - case 12: + case 15: { - if ((((pUL[0] & 18437701552104792031uL) == 3266321689424580419uL) && ((pUI[2] & 3755991007u) == 1162893652u))) + if ((((pUL[0] & 16140865742145839071uL) == 5489136224570655553uL) && ((pUI[2] & 3755991007u) == 1430736449u) && ((pUS[6] & 57311u) == 18241u) && ((pUB[14] & 223u) == 69u))) { - if (((_bits & 4096L) != 0)) + if (((_bits & 8388608L) != 0)) { - _ContentType = AppendValue(_ContentType, value); + _AcceptLanguage = AppendValue(_AcceptLanguage, value); } else { - _bits |= 4096L; - _ContentType = new StringValues(value); + _bits |= 8388608L; + _AcceptLanguage = new StringValues(value); } return; } - if ((((pUL[0] & 16131858543427968991uL) == 6292178792217067853uL) && ((pUI[2] & 3755991007u) == 1396986433u))) + if ((((pUL[0] & 16140865742145839071uL) == 4984733066305160001uL) && ((pUI[2] & 3755991007u) == 1146045262u) && ((pUS[6] & 57311u) == 20041u) && ((pUB[14] & 223u) == 71u))) { - if (((_bits & 17179869184L) != 0)) + if (((_bits & 4194304L) != 0)) { - _MaxForwards = AppendValue(_MaxForwards, value); + _AcceptEncoding = AppendValue(_AcceptEncoding, value); } else { - _bits |= 17179869184L; - _MaxForwards = new StringValues(value); + _bits |= 4194304L; + _AcceptEncoding = new StringValues(value); } return; } @@ -4707,16 +4757,16 @@ public unsafe void Append(byte[] keyBytes, int keyOffset, int keyLength, string case 16: { - if ((((pUL[0] & 18437701552104792031uL) == 3266321689424580419uL) && ((pUL[1] & 16131858542891098079uL) == 5138124782612729413uL))) + if ((((pUL[0] & 18437701552104792031uL) == 3266321689424580419uL) && ((pUL[1] & 16131858542891098079uL) == 5642809484339531596uL))) { - if (((_bits & 8192L) != 0)) + if (((_bits & 32768L) != 0)) { - _ContentEncoding = AppendValue(_ContentEncoding, value); + _ContentLocation = AppendValue(_ContentLocation, value); } else { - _bits |= 8192L; - _ContentEncoding = new StringValues(value); + _bits |= 32768L; + _ContentLocation = new StringValues(value); } return; } @@ -4735,106 +4785,70 @@ public unsafe void Append(byte[] keyBytes, int keyOffset, int keyLength, string return; } - if ((((pUL[0] & 18437701552104792031uL) == 3266321689424580419uL) && ((pUL[1] & 16131858542891098079uL) == 5642809484339531596uL))) - { - if (((_bits & 32768L) != 0)) - { - _ContentLocation = AppendValue(_ContentLocation, value); - } - else - { - _bits |= 32768L; - _ContentLocation = new StringValues(value); - } - return; - } - } - break; - - case 11: - { - if ((((pUL[0] & 18437701552104792031uL) == 3266321689424580419uL) && ((pUS[4] & 57311u) == 17485u) && ((pUB[10] & 255u) == 53u))) + if ((((pUL[0] & 18437701552104792031uL) == 3266321689424580419uL) && ((pUL[1] & 16131858542891098079uL) == 5138124782612729413uL))) { - if (((_bits & 65536L) != 0)) + if (((_bits & 8192L) != 0)) { - _ContentMD5 = AppendValue(_ContentMD5, value); + _ContentEncoding = AppendValue(_ContentEncoding, value); } else { - _bits |= 65536L; - _ContentMD5 = new StringValues(value); + _bits |= 8192L; + _ContentEncoding = new StringValues(value); } return; } } break; - case 15: + case 17: { - if ((((pUL[0] & 16140865742145839071uL) == 4984733066305160001uL) && ((pUI[2] & 3755991007u) == 1146045262u) && ((pUS[6] & 57311u) == 20041u) && ((pUB[14] & 223u) == 71u))) + if ((((pUL[0] & 16131858542891098079uL) == 5928221808112259668uL) && ((pUL[1] & 16131858542891098111uL) == 5641115115480565037uL) && ((pUB[16] & 223u) == 71u))) { - if (((_bits & 4194304L) != 0)) + if (((_bits & 64L) != 0)) { - _AcceptEncoding = AppendValue(_AcceptEncoding, value); + _TransferEncoding = AppendValue(_TransferEncoding, value); } else { - _bits |= 4194304L; - _AcceptEncoding = new StringValues(value); + _bits |= 64L; + _TransferEncoding = new StringValues(value); } return; } - if ((((pUL[0] & 16140865742145839071uL) == 5489136224570655553uL) && ((pUI[2] & 3755991007u) == 1430736449u) && ((pUS[6] & 57311u) == 18241u) && ((pUB[14] & 223u) == 69u))) + if ((((pUL[0] & 16131858542893195231uL) == 5064654363342751305uL) && ((pUL[1] & 16131858543427968991uL) == 4849894470315165001uL) && ((pUB[16] & 223u) == 69u))) { - if (((_bits & 8388608L) != 0)) + if (((_bits & 1073741824L) != 0)) { - _AcceptLanguage = AppendValue(_AcceptLanguage, value); + _IfModifiedSince = AppendValue(_IfModifiedSince, value); } else { - _bits |= 8388608L; - _AcceptLanguage = new StringValues(value); + _bits |= 1073741824L; + _IfModifiedSince = new StringValues(value); } return; } } break; - case 8: + case 19: { - if ((((pUL[0] & 16131858542893195231uL) == 5207098233614845513uL))) + if ((((pUL[0] & 16131893727263186911uL) == 6143241228466999888uL) && ((pUL[1] & 16131858542891098079uL) == 6071233043632179284uL) && ((pUS[8] & 57311u) == 20297u) && ((pUB[18] & 223u) == 78u))) { - if (((_bits & 536870912L) != 0)) + if (((_bits & 34359738368L) != 0)) { - _IfMatch = AppendValue(_IfMatch, value); + _ProxyAuthorization = AppendValue(_ProxyAuthorization, value); } else { - _bits |= 536870912L; - _IfMatch = new StringValues(value); + _bits |= 34359738368L; + _ProxyAuthorization = new StringValues(value); } return; } - if ((((pUL[0] & 16131858542893195231uL) == 4992044754422023753uL))) - { - if (((_bits & 4294967296L) != 0)) - { - _IfRange = AppendValue(_IfRange, value); - } - else - { - _bits |= 4294967296L; - _IfRange = new StringValues(value); - } - return; - } - } - break; - - case 19: - { if ((((pUL[0] & 16131858542893195231uL) == 4922237916571059785uL) && ((pUL[1] & 16131893727263186911uL) == 5283616559079179849uL) && ((pUS[8] & 57311u) == 17230u) && ((pUB[18] & 223u) == 69u))) { if (((_bits & 8589934592L) != 0)) @@ -4848,20 +4862,6 @@ public unsafe void Append(byte[] keyBytes, int keyOffset, int keyLength, string } return; } - - if ((((pUL[0] & 16131893727263186911uL) == 6143241228466999888uL) && ((pUL[1] & 16131858542891098079uL) == 6071233043632179284uL) && ((pUS[8] & 57311u) == 20297u) && ((pUB[18] & 223u) == 78u))) - { - if (((_bits & 34359738368L) != 0)) - { - _ProxyAuthorization = AppendValue(_ProxyAuthorization, value); - } - else - { - _bits |= 34359738368L; - _ProxyAuthorization = new StringValues(value); - } - return; - } } break; @@ -4883,18 +4883,18 @@ public unsafe void Append(byte[] keyBytes, int keyOffset, int keyLength, string } break; - case 9: + case 3: { - if ((((pUL[0] & 16131858542891098079uL) == 6071217693351039572uL) && ((pUB[8] & 223u) == 69u))) + if ((((pUS[0] & 57311u) == 18774u) && ((pUB[2] & 223u) == 65u))) { - if (((_bits & 549755813888L) != 0)) + if (((_bits & 256L) != 0)) { - _Translate = AppendValue(_Translate, value); + _Via = AppendValue(_Via, value); } else { - _bits |= 549755813888L; - _Translate = new StringValues(value); + _bits |= 256L; + _Via = new StringValues(value); } return; } @@ -5502,6 +5502,10 @@ public partial class FrameResponseHeaders private byte[] _rawContentLength; private byte[] _rawServer; + public bool HasConnection => ((_bits & 2L) != 0); + public bool HasTransferEncoding => ((_bits & 64L) != 0); + public bool HasContentLength => ((_bits & 2048L) != 0); + public StringValues HeaderCacheControl { get @@ -9030,10 +9034,14 @@ protected override void CopyToFast(KeyValuePair[] array, i protected void CopyToFast(ref MemoryPoolIterator2 output) { - - if (((_bits & 1L) != 0)) - { - foreach (var value in _CacheControl) + + if (((_bits & 1L) != 0)) + { + var ul = _CacheControl.Count; + for (var i = 0; i < ul; i++) + { + var value = _CacheControl[i]; + if (value != null) { if (value != null) { @@ -9041,16 +9049,22 @@ protected void CopyToFast(ref MemoryPoolIterator2 output) output.CopyFromAscii(value); } } - } - - if (((_bits & 2L) != 0)) - { - if (_rawConnection != null) + } + } + + if (((_bits & 2L) != 0)) + { + if (_rawConnection != null) + { + output.CopyFrom(_rawConnection, 0, _rawConnection.Length); + } + else + { + var ul = _Connection.Count; + for (var i = 0; i < ul; i++) { - output.CopyFrom(_rawConnection, 0, _rawConnection.Length); - } - else - foreach (var value in _Connection) + var value = _Connection[i]; + if (value != null) { if (value != null) { @@ -9058,16 +9072,23 @@ protected void CopyToFast(ref MemoryPoolIterator2 output) output.CopyFromAscii(value); } } + } } - - if (((_bits & 4L) != 0)) - { - if (_rawDate != null) + } + + if (((_bits & 4L) != 0)) + { + if (_rawDate != null) + { + output.CopyFrom(_rawDate, 0, _rawDate.Length); + } + else + { + var ul = _Date.Count; + for (var i = 0; i < ul; i++) { - output.CopyFrom(_rawDate, 0, _rawDate.Length); - } - else - foreach (var value in _Date) + var value = _Date[i]; + if (value != null) { if (value != null) { @@ -9075,11 +9096,17 @@ protected void CopyToFast(ref MemoryPoolIterator2 output) output.CopyFromAscii(value); } } + } } - - if (((_bits & 8L) != 0)) - { - foreach (var value in _KeepAlive) + } + + if (((_bits & 8L) != 0)) + { + var ul = _KeepAlive.Count; + for (var i = 0; i < ul; i++) + { + var value = _KeepAlive[i]; + if (value != null) { if (value != null) { @@ -9087,11 +9114,16 @@ protected void CopyToFast(ref MemoryPoolIterator2 output) output.CopyFromAscii(value); } } - } - - if (((_bits & 16L) != 0)) - { - foreach (var value in _Pragma) + } + } + + if (((_bits & 16L) != 0)) + { + var ul = _Pragma.Count; + for (var i = 0; i < ul; i++) + { + var value = _Pragma[i]; + if (value != null) { if (value != null) { @@ -9099,11 +9131,16 @@ protected void CopyToFast(ref MemoryPoolIterator2 output) output.CopyFromAscii(value); } } - } - - if (((_bits & 32L) != 0)) - { - foreach (var value in _Trailer) + } + } + + if (((_bits & 32L) != 0)) + { + var ul = _Trailer.Count; + for (var i = 0; i < ul; i++) + { + var value = _Trailer[i]; + if (value != null) { if (value != null) { @@ -9111,16 +9148,22 @@ protected void CopyToFast(ref MemoryPoolIterator2 output) output.CopyFromAscii(value); } } - } - - if (((_bits & 64L) != 0)) - { - if (_rawTransferEncoding != null) + } + } + + if (((_bits & 64L) != 0)) + { + if (_rawTransferEncoding != null) + { + output.CopyFrom(_rawTransferEncoding, 0, _rawTransferEncoding.Length); + } + else + { + var ul = _TransferEncoding.Count; + for (var i = 0; i < ul; i++) { - output.CopyFrom(_rawTransferEncoding, 0, _rawTransferEncoding.Length); - } - else - foreach (var value in _TransferEncoding) + var value = _TransferEncoding[i]; + if (value != null) { if (value != null) { @@ -9128,11 +9171,17 @@ protected void CopyToFast(ref MemoryPoolIterator2 output) output.CopyFromAscii(value); } } + } } - - if (((_bits & 128L) != 0)) - { - foreach (var value in _Upgrade) + } + + if (((_bits & 128L) != 0)) + { + var ul = _Upgrade.Count; + for (var i = 0; i < ul; i++) + { + var value = _Upgrade[i]; + if (value != null) { if (value != null) { @@ -9140,11 +9189,16 @@ protected void CopyToFast(ref MemoryPoolIterator2 output) output.CopyFromAscii(value); } } - } - - if (((_bits & 256L) != 0)) - { - foreach (var value in _Via) + } + } + + if (((_bits & 256L) != 0)) + { + var ul = _Via.Count; + for (var i = 0; i < ul; i++) + { + var value = _Via[i]; + if (value != null) { if (value != null) { @@ -9152,11 +9206,16 @@ protected void CopyToFast(ref MemoryPoolIterator2 output) output.CopyFromAscii(value); } } - } - - if (((_bits & 512L) != 0)) - { - foreach (var value in _Warning) + } + } + + if (((_bits & 512L) != 0)) + { + var ul = _Warning.Count; + for (var i = 0; i < ul; i++) + { + var value = _Warning[i]; + if (value != null) { if (value != null) { @@ -9164,11 +9223,16 @@ protected void CopyToFast(ref MemoryPoolIterator2 output) output.CopyFromAscii(value); } } - } - - if (((_bits & 1024L) != 0)) - { - foreach (var value in _Allow) + } + } + + if (((_bits & 1024L) != 0)) + { + var ul = _Allow.Count; + for (var i = 0; i < ul; i++) + { + var value = _Allow[i]; + if (value != null) { if (value != null) { @@ -9176,16 +9240,22 @@ protected void CopyToFast(ref MemoryPoolIterator2 output) output.CopyFromAscii(value); } } - } - - if (((_bits & 2048L) != 0)) - { - if (_rawContentLength != null) + } + } + + if (((_bits & 2048L) != 0)) + { + if (_rawContentLength != null) + { + output.CopyFrom(_rawContentLength, 0, _rawContentLength.Length); + } + else + { + var ul = _ContentLength.Count; + for (var i = 0; i < ul; i++) { - output.CopyFrom(_rawContentLength, 0, _rawContentLength.Length); - } - else - foreach (var value in _ContentLength) + var value = _ContentLength[i]; + if (value != null) { if (value != null) { @@ -9193,11 +9263,17 @@ protected void CopyToFast(ref MemoryPoolIterator2 output) output.CopyFromAscii(value); } } + } } - - if (((_bits & 4096L) != 0)) - { - foreach (var value in _ContentType) + } + + if (((_bits & 4096L) != 0)) + { + var ul = _ContentType.Count; + for (var i = 0; i < ul; i++) + { + var value = _ContentType[i]; + if (value != null) { if (value != null) { @@ -9205,11 +9281,16 @@ protected void CopyToFast(ref MemoryPoolIterator2 output) output.CopyFromAscii(value); } } - } - - if (((_bits & 8192L) != 0)) - { - foreach (var value in _ContentEncoding) + } + } + + if (((_bits & 8192L) != 0)) + { + var ul = _ContentEncoding.Count; + for (var i = 0; i < ul; i++) + { + var value = _ContentEncoding[i]; + if (value != null) { if (value != null) { @@ -9217,11 +9298,16 @@ protected void CopyToFast(ref MemoryPoolIterator2 output) output.CopyFromAscii(value); } } - } - - if (((_bits & 16384L) != 0)) - { - foreach (var value in _ContentLanguage) + } + } + + if (((_bits & 16384L) != 0)) + { + var ul = _ContentLanguage.Count; + for (var i = 0; i < ul; i++) + { + var value = _ContentLanguage[i]; + if (value != null) { if (value != null) { @@ -9229,11 +9315,16 @@ protected void CopyToFast(ref MemoryPoolIterator2 output) output.CopyFromAscii(value); } } - } - - if (((_bits & 32768L) != 0)) - { - foreach (var value in _ContentLocation) + } + } + + if (((_bits & 32768L) != 0)) + { + var ul = _ContentLocation.Count; + for (var i = 0; i < ul; i++) + { + var value = _ContentLocation[i]; + if (value != null) { if (value != null) { @@ -9241,11 +9332,16 @@ protected void CopyToFast(ref MemoryPoolIterator2 output) output.CopyFromAscii(value); } } - } - - if (((_bits & 65536L) != 0)) - { - foreach (var value in _ContentMD5) + } + } + + if (((_bits & 65536L) != 0)) + { + var ul = _ContentMD5.Count; + for (var i = 0; i < ul; i++) + { + var value = _ContentMD5[i]; + if (value != null) { if (value != null) { @@ -9253,11 +9349,16 @@ protected void CopyToFast(ref MemoryPoolIterator2 output) output.CopyFromAscii(value); } } - } - - if (((_bits & 131072L) != 0)) - { - foreach (var value in _ContentRange) + } + } + + if (((_bits & 131072L) != 0)) + { + var ul = _ContentRange.Count; + for (var i = 0; i < ul; i++) + { + var value = _ContentRange[i]; + if (value != null) { if (value != null) { @@ -9265,11 +9366,16 @@ protected void CopyToFast(ref MemoryPoolIterator2 output) output.CopyFromAscii(value); } } - } - - if (((_bits & 262144L) != 0)) - { - foreach (var value in _Expires) + } + } + + if (((_bits & 262144L) != 0)) + { + var ul = _Expires.Count; + for (var i = 0; i < ul; i++) + { + var value = _Expires[i]; + if (value != null) { if (value != null) { @@ -9277,11 +9383,16 @@ protected void CopyToFast(ref MemoryPoolIterator2 output) output.CopyFromAscii(value); } } - } - - if (((_bits & 524288L) != 0)) - { - foreach (var value in _LastModified) + } + } + + if (((_bits & 524288L) != 0)) + { + var ul = _LastModified.Count; + for (var i = 0; i < ul; i++) + { + var value = _LastModified[i]; + if (value != null) { if (value != null) { @@ -9289,11 +9400,16 @@ protected void CopyToFast(ref MemoryPoolIterator2 output) output.CopyFromAscii(value); } } - } - - if (((_bits & 1048576L) != 0)) - { - foreach (var value in _AcceptRanges) + } + } + + if (((_bits & 1048576L) != 0)) + { + var ul = _AcceptRanges.Count; + for (var i = 0; i < ul; i++) + { + var value = _AcceptRanges[i]; + if (value != null) { if (value != null) { @@ -9301,11 +9417,16 @@ protected void CopyToFast(ref MemoryPoolIterator2 output) output.CopyFromAscii(value); } } - } - - if (((_bits & 2097152L) != 0)) - { - foreach (var value in _Age) + } + } + + if (((_bits & 2097152L) != 0)) + { + var ul = _Age.Count; + for (var i = 0; i < ul; i++) + { + var value = _Age[i]; + if (value != null) { if (value != null) { @@ -9313,11 +9434,16 @@ protected void CopyToFast(ref MemoryPoolIterator2 output) output.CopyFromAscii(value); } } - } - - if (((_bits & 4194304L) != 0)) - { - foreach (var value in _ETag) + } + } + + if (((_bits & 4194304L) != 0)) + { + var ul = _ETag.Count; + for (var i = 0; i < ul; i++) + { + var value = _ETag[i]; + if (value != null) { if (value != null) { @@ -9325,11 +9451,16 @@ protected void CopyToFast(ref MemoryPoolIterator2 output) output.CopyFromAscii(value); } } - } - - if (((_bits & 8388608L) != 0)) - { - foreach (var value in _Location) + } + } + + if (((_bits & 8388608L) != 0)) + { + var ul = _Location.Count; + for (var i = 0; i < ul; i++) + { + var value = _Location[i]; + if (value != null) { if (value != null) { @@ -9337,11 +9468,16 @@ protected void CopyToFast(ref MemoryPoolIterator2 output) output.CopyFromAscii(value); } } - } - - if (((_bits & 16777216L) != 0)) - { - foreach (var value in _ProxyAutheticate) + } + } + + if (((_bits & 16777216L) != 0)) + { + var ul = _ProxyAutheticate.Count; + for (var i = 0; i < ul; i++) + { + var value = _ProxyAutheticate[i]; + if (value != null) { if (value != null) { @@ -9349,11 +9485,16 @@ protected void CopyToFast(ref MemoryPoolIterator2 output) output.CopyFromAscii(value); } } - } - - if (((_bits & 33554432L) != 0)) - { - foreach (var value in _RetryAfter) + } + } + + if (((_bits & 33554432L) != 0)) + { + var ul = _RetryAfter.Count; + for (var i = 0; i < ul; i++) + { + var value = _RetryAfter[i]; + if (value != null) { if (value != null) { @@ -9361,16 +9502,22 @@ protected void CopyToFast(ref MemoryPoolIterator2 output) output.CopyFromAscii(value); } } - } - - if (((_bits & 67108864L) != 0)) - { - if (_rawServer != null) + } + } + + if (((_bits & 67108864L) != 0)) + { + if (_rawServer != null) + { + output.CopyFrom(_rawServer, 0, _rawServer.Length); + } + else + { + var ul = _Server.Count; + for (var i = 0; i < ul; i++) { - output.CopyFrom(_rawServer, 0, _rawServer.Length); - } - else - foreach (var value in _Server) + var value = _Server[i]; + if (value != null) { if (value != null) { @@ -9378,11 +9525,17 @@ protected void CopyToFast(ref MemoryPoolIterator2 output) output.CopyFromAscii(value); } } + } } - - if (((_bits & 134217728L) != 0)) - { - foreach (var value in _SetCookie) + } + + if (((_bits & 134217728L) != 0)) + { + var ul = _SetCookie.Count; + for (var i = 0; i < ul; i++) + { + var value = _SetCookie[i]; + if (value != null) { if (value != null) { @@ -9390,11 +9543,16 @@ protected void CopyToFast(ref MemoryPoolIterator2 output) output.CopyFromAscii(value); } } - } - - if (((_bits & 268435456L) != 0)) - { - foreach (var value in _Vary) + } + } + + if (((_bits & 268435456L) != 0)) + { + var ul = _Vary.Count; + for (var i = 0; i < ul; i++) + { + var value = _Vary[i]; + if (value != null) { if (value != null) { @@ -9402,11 +9560,16 @@ protected void CopyToFast(ref MemoryPoolIterator2 output) output.CopyFromAscii(value); } } - } - - if (((_bits & 536870912L) != 0)) - { - foreach (var value in _WWWAuthenticate) + } + } + + if (((_bits & 536870912L) != 0)) + { + var ul = _WWWAuthenticate.Count; + for (var i = 0; i < ul; i++) + { + var value = _WWWAuthenticate[i]; + if (value != null) { if (value != null) { @@ -9414,11 +9577,16 @@ protected void CopyToFast(ref MemoryPoolIterator2 output) output.CopyFromAscii(value); } } - } - - if (((_bits & 1073741824L) != 0)) - { - foreach (var value in _AccessControlAllowCredentials) + } + } + + if (((_bits & 1073741824L) != 0)) + { + var ul = _AccessControlAllowCredentials.Count; + for (var i = 0; i < ul; i++) + { + var value = _AccessControlAllowCredentials[i]; + if (value != null) { if (value != null) { @@ -9426,11 +9594,16 @@ protected void CopyToFast(ref MemoryPoolIterator2 output) output.CopyFromAscii(value); } } - } - - if (((_bits & 2147483648L) != 0)) - { - foreach (var value in _AccessControlAllowHeaders) + } + } + + if (((_bits & 2147483648L) != 0)) + { + var ul = _AccessControlAllowHeaders.Count; + for (var i = 0; i < ul; i++) + { + var value = _AccessControlAllowHeaders[i]; + if (value != null) { if (value != null) { @@ -9438,11 +9611,16 @@ protected void CopyToFast(ref MemoryPoolIterator2 output) output.CopyFromAscii(value); } } - } - - if (((_bits & 4294967296L) != 0)) - { - foreach (var value in _AccessControlAllowMethods) + } + } + + if (((_bits & 4294967296L) != 0)) + { + var ul = _AccessControlAllowMethods.Count; + for (var i = 0; i < ul; i++) + { + var value = _AccessControlAllowMethods[i]; + if (value != null) { if (value != null) { @@ -9450,11 +9628,16 @@ protected void CopyToFast(ref MemoryPoolIterator2 output) output.CopyFromAscii(value); } } - } - - if (((_bits & 8589934592L) != 0)) - { - foreach (var value in _AccessControlAllowOrigin) + } + } + + if (((_bits & 8589934592L) != 0)) + { + var ul = _AccessControlAllowOrigin.Count; + for (var i = 0; i < ul; i++) + { + var value = _AccessControlAllowOrigin[i]; + if (value != null) { if (value != null) { @@ -9462,11 +9645,16 @@ protected void CopyToFast(ref MemoryPoolIterator2 output) output.CopyFromAscii(value); } } - } - - if (((_bits & 17179869184L) != 0)) - { - foreach (var value in _AccessControlExposeHeaders) + } + } + + if (((_bits & 17179869184L) != 0)) + { + var ul = _AccessControlExposeHeaders.Count; + for (var i = 0; i < ul; i++) + { + var value = _AccessControlExposeHeaders[i]; + if (value != null) { if (value != null) { @@ -9474,11 +9662,16 @@ protected void CopyToFast(ref MemoryPoolIterator2 output) output.CopyFromAscii(value); } } - } - - if (((_bits & 34359738368L) != 0)) - { - foreach (var value in _AccessControlMaxAge) + } + } + + if (((_bits & 34359738368L) != 0)) + { + var ul = _AccessControlMaxAge.Count; + for (var i = 0; i < ul; i++) + { + var value = _AccessControlMaxAge[i]; + if (value != null) { if (value != null) { @@ -9486,8 +9679,9 @@ protected void CopyToFast(ref MemoryPoolIterator2 output) output.CopyFromAscii(value); } } - } - + } + } + } public unsafe void Append(byte[] keyBytes, int keyOffset, int keyLength, string value) { diff --git a/src/Microsoft.AspNet.Server.Kestrel/Http/FrameResponseHeaders.cs b/src/Microsoft.AspNet.Server.Kestrel/Http/FrameResponseHeaders.cs index 840d44ce8..c8edaf79e 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Http/FrameResponseHeaders.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Http/FrameResponseHeaders.cs @@ -13,13 +13,6 @@ public partial class FrameResponseHeaders : FrameHeaders private static readonly byte[] _CrLf = new[] { (byte)'\r', (byte)'\n' }; private static readonly byte[] _colonSpace = new[] { (byte)':', (byte)' ' }; - public bool HasConnection => HeaderConnection.Count != 0; - - public bool HasTransferEncoding => HeaderTransferEncoding.Count != 0; - - public bool HasContentLength => HeaderContentLength.Count != 0; - - public Enumerator GetEnumerator() { return new Enumerator(this); @@ -33,12 +26,14 @@ protected override IEnumerator> GetEnumerator public void CopyTo(ref MemoryPoolIterator2 output) { CopyToFast(ref output); - if (MaybeUnknown != null) + if (MaybeUnknown != null && MaybeUnknown.Count > 0) { foreach (var kv in MaybeUnknown) { - foreach (var value in kv.Value) + var ul = kv.Value.Count; + for (var i = 0; i < ul; i++) { + var value = kv.Value[i]; if (value != null) { output.CopyFrom(_CrLf, 0, 2); diff --git a/src/Microsoft.AspNet.Server.Kestrel/Infrastructure/MemoryPoolIterator2.Generated.cs b/src/Microsoft.AspNet.Server.Kestrel/Infrastructure/MemoryPoolIterator2.Generated.cs new file mode 100644 index 000000000..1ebddef20 --- /dev/null +++ b/src/Microsoft.AspNet.Server.Kestrel/Infrastructure/MemoryPoolIterator2.Generated.cs @@ -0,0 +1,338 @@ + +using System; + +namespace Microsoft.AspNet.Server.Kestrel.Infrastructure +{ + public partial struct MemoryPoolIterator2 + { + private const byte _colon = 58; + private const int _headerAcce = 1701012321; + private const int _headerAllo = 1869376609; + private const int _headerAuth = 1752462689; + private const int _headerCach = 1751343459; + private const int _headerConn = 1852731235; + private const int _headerCont = 1953394531; + private const int _headerCook = 1802465123; + private const int _headerDate = 1702125924; + private const int _headerExpe = 1701869669; + private const int _headerExpi = 1768978533; + private const int _headerFrom = 1836020326; + private const int _headerHost = 1953722216; + private const int _headerIf_M = 1831691881; + private const int _headerIf_N = 1848469097; + private const int _headerIf_R = 1915577961; + private const int _headerIf_U = 1965909609; + private const int _headerKeep = 1885693291; + private const int _headerLast = 1953718636; + private const int _headerMax_ = 762863981; + private const int _headerOrig = 1734963823; + private const int _headerPrag = 1734439536; + private const int _headerProx = 2020569712; + private const int _headerRang = 1735287154; + private const int _headerRefe = 1701209458; + private const int _headerTrai = 1767993972; + private const int _headerTran = 1851880052; + private const int _headerUpgr = 1919381621; + private const int _headerUser = 1919251317; + private const int _headerWarn = 1852989815; + + + public unsafe bool SeekCommonHeader() + { + if (BitConverter.IsLittleEndian != true) + { + return false; + } + + if (IsDefault) + { + return false; + } + + var block = _block; + var index = _index; + var following = block.End - index; + + if (following < 4) + { + return false; + } + + fixed (byte* ptr = &block.Array[index]) + { + var fourLowerChars = *(int*)(ptr) | 0x20202020; + + switch (fourLowerChars) + { + case _headerHost: + if (following >= 4 && *(ptr + 4) == _colon) // Host + { + _index = index + 4; + return true; + } + return false; + case _headerFrom: + if (following >= 4 && *(ptr + 4) == _colon) // From + { + _index = index + 4; + return true; + } + return false; + case _headerDate: + if (following >= 4 && *(ptr + 4) == _colon) // Date + { + _index = index + 4; + return true; + } + return false; + case _headerRang: + if (following >= 5 && *(ptr + 5) == _colon) // Range + { + _index = index + 5; + return true; + } + return false; + case _headerAllo: + if (following >= 5 && *(ptr + 5) == _colon) // Allow + { + _index = index + 5; + return true; + } + return false; + case _headerPrag: + if (following >= 6 && *(ptr + 6) == _colon) // Pragma + { + _index = index + 6; + return true; + } + return false; + case _headerOrig: + if (following >= 6 && *(ptr + 6) == _colon) // Origin + { + _index = index + 6; + return true; + } + return false; + case _headerExpe: + if (following >= 6 && *(ptr + 6) == _colon) // Expect + { + _index = index + 6; + return true; + } + return false; + case _headerCook: + if (following >= 6 && *(ptr + 6) == _colon) // Cookie + { + _index = index + 6; + return true; + } + return false; + case _headerAcce: + if (following >= 6 && *(ptr + 6) == _colon) // Accept + { + _index = index + 6; + return true; + } + + if (following >= 14 && *(ptr + 14) == _colon) // Accept-Charset + { + _index = index + 14; + return true; + } + + if (following >= 15 && *(ptr + 15) == _colon) // Accept-Language, Accept-Encoding + { + _index = index + 15; + return true; + } + + if (following >= 29 && *(ptr + 29) == _colon) // Access-Control-Request-Method + { + _index = index + 29; + return true; + } + + if (following >= 30 && *(ptr + 30) == _colon) // Access-Control-Request-Headers + { + _index = index + 30; + return true; + } + return false; + case _headerWarn: + if (following >= 7 && *(ptr + 7) == _colon) // Warning + { + _index = index + 7; + return true; + } + return false; + case _headerUpgr: + if (following >= 7 && *(ptr + 7) == _colon) // Upgrade + { + _index = index + 7; + return true; + } + return false; + case _headerTrai: + if (following >= 7 && *(ptr + 7) == _colon) // Trailer + { + _index = index + 7; + return true; + } + return false; + case _headerRefe: + if (following >= 7 && *(ptr + 7) == _colon) // Referer + { + _index = index + 7; + return true; + } + return false; + case _headerExpi: + if (following >= 7 && *(ptr + 7) == _colon) // Expires + { + _index = index + 7; + return true; + } + return false; + case _headerIf_R: + if (following >= 8 && *(ptr + 8) == _colon) // If-Range + { + _index = index + 8; + return true; + } + return false; + case _headerIf_M: + if (following >= 8 && *(ptr + 8) == _colon) // If-Match + { + _index = index + 8; + return true; + } + + if (following >= 17 && *(ptr + 17) == _colon) // If-Modified-Since + { + _index = index + 17; + return true; + } + return false; + case _headerTran: + if (following >= 9 && *(ptr + 9) == _colon) // Translate + { + _index = index + 9; + return true; + } + + if (following >= 17 && *(ptr + 17) == _colon) // Transfer-Encoding + { + _index = index + 17; + return true; + } + return false; + case _headerUser: + if (following >= 10 && *(ptr + 10) == _colon) // User-Agent + { + _index = index + 10; + return true; + } + return false; + case _headerKeep: + if (following >= 10 && *(ptr + 10) == _colon) // Keep-Alive + { + _index = index + 10; + return true; + } + return false; + case _headerConn: + if (following >= 10 && *(ptr + 10) == _colon) // Connection + { + _index = index + 10; + return true; + } + return false; + case _headerCont: + if (following >= 11 && *(ptr + 11) == _colon) // Content-MD5 + { + _index = index + 11; + return true; + } + + if (following >= 12 && *(ptr + 12) == _colon) // Content-Type + { + _index = index + 12; + return true; + } + + if (following >= 13 && *(ptr + 13) == _colon) // Content-Range + { + _index = index + 13; + return true; + } + + if (following >= 14 && *(ptr + 14) == _colon) // Content-Length + { + _index = index + 14; + return true; + } + + if (following >= 16 && *(ptr + 16) == _colon) // Content-Location, Content-Language, Content-Encoding + { + _index = index + 16; + return true; + } + return false; + case _headerMax_: + if (following >= 12 && *(ptr + 12) == _colon) // Max-Forwards + { + _index = index + 12; + return true; + } + return false; + case _headerLast: + if (following >= 13 && *(ptr + 13) == _colon) // Last-Modified + { + _index = index + 13; + return true; + } + return false; + case _headerIf_N: + if (following >= 13 && *(ptr + 13) == _colon) // If-None-Match + { + _index = index + 13; + return true; + } + return false; + case _headerCach: + if (following >= 13 && *(ptr + 13) == _colon) // Cache-Control + { + _index = index + 13; + return true; + } + return false; + case _headerAuth: + if (following >= 13 && *(ptr + 13) == _colon) // Authorization + { + _index = index + 13; + return true; + } + return false; + case _headerProx: + if (following >= 19 && *(ptr + 19) == _colon) // Proxy-Authorization + { + _index = index + 19; + return true; + } + return false; + case _headerIf_U: + if (following >= 19 && *(ptr + 19) == _colon) // If-Unmodified-Since + { + _index = index + 19; + return true; + } + return false; + + default: + return false; + } + } + + } + } +} diff --git a/src/Microsoft.AspNet.Server.Kestrel/Infrastructure/MemoryPoolIterator2.cs b/src/Microsoft.AspNet.Server.Kestrel/Infrastructure/MemoryPoolIterator2.cs index 265c6b5d0..68cf41f86 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Infrastructure/MemoryPoolIterator2.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Infrastructure/MemoryPoolIterator2.cs @@ -7,7 +7,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Infrastructure { - public struct MemoryPoolIterator2 + public partial struct MemoryPoolIterator2 { private readonly static int _vectorSpan = Vector.Count; diff --git a/src/Microsoft.AspNet.Server.Kestrel/project.json b/src/Microsoft.AspNet.Server.Kestrel/project.json index 2e0caab7c..02204db35 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/project.json +++ b/src/Microsoft.AspNet.Server.Kestrel/project.json @@ -74,7 +74,7 @@ "scripts": { "prepare": [ "dnu restore ../../tools/Microsoft.AspNet.Server.Kestrel.GeneratedCode", - "dnx -p ../../tools/Microsoft.AspNet.Server.Kestrel.GeneratedCode run Http/FrameHeaders.Generated.cs Http/Frame.Generated.cs" + "dnx -p ../../tools/Microsoft.AspNet.Server.Kestrel.GeneratedCode run Http/FrameHeaders.Generated.cs Http/Frame.Generated.cs Infrastructure/MemoryPoolIterator2.Generated.cs" ], "postrestore": [ "dnu restore ../../tools/Microsoft.AspNet.Server.Kestrel.LibuvCopier", diff --git a/tools/Microsoft.AspNet.Server.Kestrel.GeneratedCode/KnownHeaders.cs b/tools/Microsoft.AspNet.Server.Kestrel.GeneratedCode/KnownHeaders.cs index 9f7c72015..93a660240 100644 --- a/tools/Microsoft.AspNet.Server.Kestrel.GeneratedCode/KnownHeaders.cs +++ b/tools/Microsoft.AspNet.Server.Kestrel.GeneratedCode/KnownHeaders.cs @@ -15,6 +15,110 @@ static string Each(IEnumerable values, Func formatter) return values.Any() ? values.Select(formatter).Aggregate((a, b) => a + b) : ""; } + static string[] commonHeaders = new[] + { + "Cache-Control", + "Connection", + "Date", + "Keep-Alive", + "Pragma", + "Trailer", + "Transfer-Encoding", + "Upgrade", + "Via", + "Warning", + "Allow", + "Content-Length", + "Content-Type", + "Content-Encoding", + "Content-Language", + "Content-Location", + "Content-MD5", + "Content-Range", + "Expires", + "Last-Modified" + }; + // http://www.w3.org/TR/cors/#syntax + static string[] corsRequestHeaders = new[] + { + "Origin", + "Access-Control-Request-Method", + "Access-Control-Request-Headers", + }; + static KnownHeader[] requestHeaders = commonHeaders.Concat(new[] + { + "Accept", + "Accept-Charset", + "Accept-Encoding", + "Accept-Language", + "Authorization", + "Cookie", + "Expect", + "From", + "Host", + "If-Match", + "If-Modified-Since", + "If-None-Match", + "If-Range", + "If-Unmodified-Since", + "Max-Forwards", + "Proxy-Authorization", + "Referer", + "Range", + "TE", + "Translate", + "User-Agent", + }).Concat(corsRequestHeaders).Select((header, index) => new KnownHeader + { + Name = header, + Index = index + }).ToArray(); + + static string[] enhancedHeaders = new[] + { + "Connection", + "Server", + "Date", + "Transfer-Encoding", + "Content-Length", + }; + // http://www.w3.org/TR/cors/#syntax + static string[] corsResponseHeaders = new[] + { + "Access-Control-Allow-Credentials", + "Access-Control-Allow-Headers", + "Access-Control-Allow-Methods", + "Access-Control-Allow-Origin", + "Access-Control-Expose-Headers", + "Access-Control-Max-Age", + }; + static string[] fastCheckHeaders = new[] + { + "Connection", + "Transfer-Encoding", + "Content-Length", + }; + + static KnownHeader[] responseHeaders = commonHeaders.Concat(new[] + { + "Accept-Ranges", + "Age", + "ETag", + "Location", + "Proxy-Autheticate", + "Retry-After", + "Server", + "Set-Cookie", + "Vary", + "WWW-Authenticate", + }).Concat(corsResponseHeaders).Select((header, index) => new KnownHeader + { + Name = header, + Index = index, + EnhancedSetter = enhancedHeaders.Contains(header), + FastCheck = fastCheckHeaders.Contains(header) + }).ToArray(); + class KnownHeader { public string Name { get; set; } @@ -25,6 +129,7 @@ class KnownHeader public int BytesOffset { get; set; } public int BytesCount { get; set; } public bool EnhancedSetter { get; set; } + public bool FastCheck { get; set; } public string TestBit() => $"((_bits & {1L << Index}L) != 0)"; public string SetBit() => $"_bits |= {1L << Index}L"; public string ClearBit() => $"_bits &= ~{1L << Index}L"; @@ -78,108 +183,28 @@ public virtual void BeforeCompile(BeforeCompileContext context) var syntaxTree = Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTree.ParseText(GeneratedFile()); context.Compilation = context.Compilation.AddSyntaxTrees(syntaxTree); } - public static string GeneratedFile() + + public unsafe static int IntValue(string fourLowerChars) { - var commonHeaders = new[] + var buffer = new byte[4]; + fixed (byte* ptr = buffer) { - "Cache-Control", - "Connection", - "Date", - "Keep-Alive", - "Pragma", - "Trailer", - "Transfer-Encoding", - "Upgrade", - "Via", - "Warning", - "Allow", - "Content-Length", - "Content-Type", - "Content-Encoding", - "Content-Language", - "Content-Location", - "Content-MD5", - "Content-Range", - "Expires", - "Last-Modified" - }; - // http://www.w3.org/TR/cors/#syntax - var corsRequestHeaders = new[] - { - "Origin", - "Access-Control-Request-Method", - "Access-Control-Request-Headers", - }; - var requestHeaders = commonHeaders.Concat(new[] - { - "Accept", - "Accept-Charset", - "Accept-Encoding", - "Accept-Language", - "Authorization", - "Cookie", - "Expect", - "From", - "Host", - "If-Match", - "If-Modified-Since", - "If-None-Match", - "If-Range", - "If-Unmodified-Since", - "Max-Forwards", - "Proxy-Authorization", - "Referer", - "Range", - "TE", - "Translate", - "User-Agent", - }).Concat(corsRequestHeaders).Select((header, index) => new KnownHeader - { - Name = header, - Index = index - }).ToArray(); - var enhancedHeaders = new[] - { - "Connection", - "Server", - "Date", - "Transfer-Encoding", - "Content-Length", - }; - // http://www.w3.org/TR/cors/#syntax - var corsResponseHeaders = new[] - { - "Access-Control-Allow-Credentials", - "Access-Control-Allow-Headers", - "Access-Control-Allow-Methods", - "Access-Control-Allow-Origin", - "Access-Control-Expose-Headers", - "Access-Control-Max-Age", - }; - var responseHeaders = commonHeaders.Concat(new[] - { - "Accept-Ranges", - "Age", - "ETag", - "Location", - "Proxy-Autheticate", - "Retry-After", - "Server", - "Set-Cookie", - "Vary", - "WWW-Authenticate", - }).Concat(corsResponseHeaders).Select((header, index) => new KnownHeader - { - Name = header, - Index = index, - EnhancedSetter = enhancedHeaders.Contains(header) - }).ToArray(); + buffer[0] = (byte)fourLowerChars[0]; + buffer[1] = (byte)fourLowerChars[1]; + buffer[2] = (byte)fourLowerChars[2]; + buffer[3] = (byte)fourLowerChars[3]; + return *(int*)ptr; + } + } + + public static string GeneratedFile() + { var loops = new[] { new { Headers = requestHeaders, - HeadersByLength = requestHeaders.GroupBy(x => x.Name.Length), + HeadersByLength = requestHeaders.OrderBy(x => x.Name.Length < 4 ? x.Name.Length + 19 : x.Name.Length).ThenByDescending(s => s.Name).GroupBy(x => x.Name.Length), ClassName = "FrameRequestHeaders", Bytes = default(byte[]) }, @@ -191,6 +216,7 @@ public static string GeneratedFile() Bytes = responseHeaders.SelectMany(header => header.Bytes).ToArray() } }; + foreach (var loop in loops.Where(l => l.Bytes != null)) { var offset = 0; @@ -204,7 +230,6 @@ public static string GeneratedFile() return $@" using System; using System.Collections.Generic; -using System.Text; using Microsoft.AspNet.Server.Kestrel.Infrastructure; using Microsoft.Extensions.Primitives; @@ -225,6 +250,8 @@ public partial class {loop.ClassName} private StringValues _" + header.Identifier + ";")} {Each(loop.Headers.Where(header => header.EnhancedSetter), header => @" private byte[] _raw" + header.Identifier + ";")} + {Each(loop.Headers.Where(header => header.FastCheck), header => @" + public bool Has" + header.Identifier + $" => {header.TestBit()};")} {Each(loop.Headers, header => $@" public StringValues Header{header.Identifier} {{ @@ -399,15 +426,20 @@ protected override void CopyToFast(KeyValuePair[] array, i {(loop.ClassName == "FrameResponseHeaders" ? $@" protected void CopyToFast(ref MemoryPoolIterator2 output) {{ - {Each(loop.Headers, header => $@" - if ({header.TestBit()}) - {{ {(header.EnhancedSetter == false ? "" : $@" - if (_raw{header.Identifier} != null) + {Each(loop.Headers, header => $@" + if ({header.TestBit()}) + {{ {(header.EnhancedSetter == false ? "" : $@" + if (_raw{header.Identifier} != null) + {{ + output.CopyFrom(_raw{header.Identifier}, 0, _raw{header.Identifier}.Length); + }} + else + {{")} + var ul = _{header.Identifier}.Count; + for (var i = 0; i < ul; i++) {{ - output.CopyFrom(_raw{header.Identifier}, 0, _raw{header.Identifier}.Length); - }} - else ")} - foreach (var value in _{header.Identifier}) + var value = _{header.Identifier}[i]; + if (value != null) {{ if (value != null) {{ @@ -415,8 +447,10 @@ protected void CopyToFast(ref MemoryPoolIterator2 output) output.CopyFromAscii(value); }} }} - }} - ")} + }}{(header.EnhancedSetter == false ? "" : @" + }")} + }} + ")} }}" : "")} public unsafe void Append(byte[] keyBytes, int keyOffset, int keyLength, string value) {{ @@ -488,6 +522,68 @@ public bool MoveNext() }} ")}}}"; } + + public static string GeneratedMemoryPoolIterator2() + { + return $@" +using System; + +namespace Microsoft.AspNet.Server.Kestrel.Infrastructure +{{ + public partial struct MemoryPoolIterator2 + {{ + private const byte _colon = {(byte)':'}; +{Each(requestHeaders.Where(x => x.Name.Length >= 4).OrderBy(x => x.Name.Substring(0, 4)).ThenBy(x => x.Name.Length).GroupBy(x => x.Name.Substring(0, 4)), header => +$@" private const int _header{header.Key.Substring(0, 4).Replace('-', '_')} = {IntValue(header.Key.Substring(0, 4).ToLower())}; +")} + + public unsafe bool SeekCommonHeader() + {{ + if (BitConverter.IsLittleEndian != {BitConverter.IsLittleEndian.ToString().ToLower()}) + {{ + return false; + }} + + if (IsDefault) + {{ + return false; + }} + + var block = _block; + var index = _index; + var following = block.End - index; + + if (following < 4) + {{ + return false; + }} + + fixed (byte* ptr = &block.Array[index]) + {{ + var fourLowerChars = *(int*)(ptr) | 0x20202020; + + switch (fourLowerChars) + {{ + {Each(requestHeaders.Where(x => x.Name.Length >= 4).OrderBy(x => x.Name.Length).ThenByDescending(x => x.Name).GroupBy(x => x.Name.Substring(0, 4)), headers => + $@" case _header{headers.Key.Substring(0, 4).Replace('-', '_')}:{Each(headers.GroupBy(x => x.Name.Length), headersByLength => $@" + if (following >= {headersByLength.Key} && *(ptr + {headersByLength.Key}) == _colon) // {string.Join(", ", headersByLength.Select(header => header.Name))} + {{ + _index = index + {headersByLength.Key}; + return true; + }} + ")} return false; + ")} + default: + return false; + }} + }} + + }} + }} +}} +"; + } + public virtual void AfterCompile(AfterCompileContext context) { } diff --git a/tools/Microsoft.AspNet.Server.Kestrel.GeneratedCode/Program.cs b/tools/Microsoft.AspNet.Server.Kestrel.GeneratedCode/Program.cs index 3727772c0..6faa4a1a4 100644 --- a/tools/Microsoft.AspNet.Server.Kestrel.GeneratedCode/Program.cs +++ b/tools/Microsoft.AspNet.Server.Kestrel.GeneratedCode/Program.cs @@ -9,6 +9,7 @@ public int Main(string[] args) { var text0 = KnownHeaders.GeneratedFile(); var text1 = FrameFeatureCollection.GeneratedFile(); + var text2 = KnownHeaders.GeneratedMemoryPoolIterator2(); if (args.Length == 1) { @@ -32,6 +33,26 @@ public int Main(string[] args) File.WriteAllText(args[1], text1); } } + else if (args.Length == 3) + { + var existing0 = File.Exists(args[0]) ? File.ReadAllText(args[0]) : ""; + if (!string.Equals(text0, existing0)) + { + File.WriteAllText(args[0], text0); + } + + var existing1 = File.Exists(args[1]) ? File.ReadAllText(args[1]) : ""; + if (!string.Equals(text1, existing1)) + { + File.WriteAllText(args[1], text1); + } + + var existing2 = File.Exists(args[2]) ? File.ReadAllText(args[2]) : ""; + if (!string.Equals(text2, existing2)) + { + File.WriteAllText(args[2], text2); + } + } else { Console.WriteLine(text0); diff --git a/tools/Microsoft.AspNet.Server.Kestrel.GeneratedCode/project.json b/tools/Microsoft.AspNet.Server.Kestrel.GeneratedCode/project.json index ede3a70f5..db7407d00 100644 --- a/tools/Microsoft.AspNet.Server.Kestrel.GeneratedCode/project.json +++ b/tools/Microsoft.AspNet.Server.Kestrel.GeneratedCode/project.json @@ -11,6 +11,8 @@ "run": "Microsoft.AspNet.Server.Kestrel.GeneratedCode" }, + "compilationOptions": { "allowUnsafe": true }, + "frameworks": { "dnx451": { "frameworkAssemblies": {