diff --git a/src/Microsoft.AspNet.Server.Kestrel/Http/Frame.cs b/src/Microsoft.AspNet.Server.Kestrel/Http/Frame.cs index d5dc958080..ded01e3efa 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Http/Frame.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Http/Frame.cs @@ -8,6 +8,7 @@ using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; +using Microsoft.Framework.Primitives; // ReSharper disable AccessToModifiedClosure @@ -55,13 +56,13 @@ namespace Microsoft.AspNet.Server.Kestrel.Http public string Path { get; set; } public string QueryString { get; set; } public string HttpVersion { get; set; } - public IDictionary RequestHeaders { get; set; } + public IDictionary RequestHeaders { get; set; } public MessageBody MessageBody { get; set; } public Stream RequestBody { get; set; } public int StatusCode { get; set; } public string ReasonPhrase { get; set; } - public IDictionary ResponseHeaders { get; set; } + public IDictionary ResponseHeaders { get; set; } public Stream ResponseBody { get; set; } public Stream DuplexStream { get; set; } @@ -357,7 +358,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http { if (_responseStarted) return; - string[] expect; + StringValues expect; if (HttpVersion.Equals("HTTP/1.1") && RequestHeaders.TryGetValue("Expect", out expect) && (expect.FirstOrDefault() ?? "").Equals("100-continue", StringComparison.OrdinalIgnoreCase)) @@ -444,7 +445,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http private Tuple, IDisposable> CreateResponseHeader( string status, bool appCompleted, - IEnumerable> headers) + IEnumerable> headers) { var writer = new MemoryPoolTextWriter(Memory); writer.Write(HttpVersion); diff --git a/src/Microsoft.AspNet.Server.Kestrel/Http/FrameHeaders.Generated.cs b/src/Microsoft.AspNet.Server.Kestrel/Http/FrameHeaders.Generated.cs index 686527fadc..a79b61d4c4 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Http/FrameHeaders.Generated.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Http/FrameHeaders.Generated.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; +using Microsoft.Framework.Primitives; namespace Microsoft.AspNet.Server.Kestrel.Http { @@ -8,8 +9,8 @@ namespace Microsoft.AspNet.Server.Kestrel.Http { public FrameResponseHeaders() { - _Server = new[] { "Kestrel" }; - _Date = new[] { DateTime.UtcNow.ToString("r") }; + _Server = "Kestrel"; + _Date = DateTime.UtcNow.ToString("r"); _bits = 67108868L; } } @@ -18,47 +19,47 @@ namespace Microsoft.AspNet.Server.Kestrel.Http { long _bits = 0; - string[] _CacheControl; - string[] _Connection; - string[] _Date; - string[] _KeepAlive; - string[] _Pragma; - string[] _Trailer; - string[] _TransferEncoding; - string[] _Upgrade; - string[] _Via; - string[] _Warning; - string[] _Allow; - string[] _ContentLength; - string[] _ContentType; - string[] _ContentEncoding; - string[] _ContentLanguage; - string[] _ContentLocation; - string[] _ContentMD5; - string[] _ContentRange; - string[] _Expires; - string[] _LastModified; - string[] _Accept; - string[] _AcceptCharset; - string[] _AcceptEncoding; - string[] _AcceptLanguage; - string[] _Authorization; - string[] _Cookie; - string[] _Expect; - string[] _From; - string[] _Host; - string[] _IfMatch; - string[] _IfModifiedSince; - string[] _IfNoneMatch; - string[] _IfRange; - string[] _IfUnmodifiedSince; - string[] _MaxForwards; - string[] _ProxyAuthorization; - string[] _Referer; - string[] _Range; - string[] _TE; - string[] _Translate; - string[] _UserAgent; + StringValues _CacheControl; + StringValues _Connection; + StringValues _Date; + StringValues _KeepAlive; + StringValues _Pragma; + StringValues _Trailer; + StringValues _TransferEncoding; + StringValues _Upgrade; + StringValues _Via; + StringValues _Warning; + StringValues _Allow; + StringValues _ContentLength; + StringValues _ContentType; + StringValues _ContentEncoding; + StringValues _ContentLanguage; + StringValues _ContentLocation; + StringValues _ContentMD5; + StringValues _ContentRange; + StringValues _Expires; + StringValues _LastModified; + StringValues _Accept; + StringValues _AcceptCharset; + StringValues _AcceptEncoding; + StringValues _AcceptLanguage; + StringValues _Authorization; + StringValues _Cookie; + StringValues _Expect; + StringValues _From; + StringValues _Host; + StringValues _IfMatch; + StringValues _IfModifiedSince; + StringValues _IfNoneMatch; + StringValues _IfRange; + StringValues _IfUnmodifiedSince; + StringValues _MaxForwards; + StringValues _ProxyAuthorization; + StringValues _Referer; + StringValues _Range; + StringValues _TE; + StringValues _Translate; + StringValues _UserAgent; protected override int GetCountFast() { @@ -272,7 +273,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http return count; } - protected override string[] GetValueFast(string key) + protected override StringValues GetValueFast(string key) { switch(key.Length) { @@ -843,7 +844,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http return MaybeUnknown[key]; } - protected override bool TryGetValueFast(string key, out string[] value) + protected override bool TryGetValueFast(string key, out StringValues value) { switch(key.Length) { @@ -858,7 +859,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -872,7 +873,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -886,7 +887,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -900,7 +901,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -914,7 +915,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -932,7 +933,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -946,7 +947,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -960,7 +961,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -978,7 +979,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -992,7 +993,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -1006,7 +1007,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -1024,7 +1025,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -1038,7 +1039,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -1052,7 +1053,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -1066,7 +1067,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -1084,7 +1085,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -1098,7 +1099,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -1112,7 +1113,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -1126,7 +1127,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -1140,7 +1141,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -1158,7 +1159,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -1172,7 +1173,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -1190,7 +1191,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -1208,7 +1209,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -1222,7 +1223,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -1240,7 +1241,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -1254,7 +1255,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -1272,7 +1273,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -1286,7 +1287,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -1304,7 +1305,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -1318,7 +1319,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -1332,7 +1333,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -1350,7 +1351,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -1368,7 +1369,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -1382,7 +1383,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -1400,7 +1401,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -1414,7 +1415,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -1432,7 +1433,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -1446,7 +1447,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -1464,7 +1465,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -1482,18 +1483,18 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } } break; } - value = null; + value = StringValues.Empty; return MaybeUnknown?.TryGetValue(key, out value) ?? false; } - protected override void SetValueFast(string key, string[] value) + protected override void SetValueFast(string key, StringValues value) { switch(key.Length) { @@ -1855,7 +1856,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http Unknown[key] = value; } - protected override void AddValueFast(string key, string[] value) + protected override void AddValueFast(string key, StringValues value) { switch(key.Length) { @@ -2995,7 +2996,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http MaybeUnknown?.Clear(); } - protected override void CopyToFast(KeyValuePair[] array, int arrayIndex) + protected override void CopyToFast(KeyValuePair[] array, int arrayIndex) { if (arrayIndex < 0) { @@ -3010,7 +3011,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Cache-Control", _CacheControl); + array[arrayIndex] = new KeyValuePair("Cache-Control", _CacheControl); ++arrayIndex; } @@ -3021,7 +3022,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Connection", _Connection); + array[arrayIndex] = new KeyValuePair("Connection", _Connection); ++arrayIndex; } @@ -3032,7 +3033,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Date", _Date); + array[arrayIndex] = new KeyValuePair("Date", _Date); ++arrayIndex; } @@ -3043,7 +3044,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Keep-Alive", _KeepAlive); + array[arrayIndex] = new KeyValuePair("Keep-Alive", _KeepAlive); ++arrayIndex; } @@ -3054,7 +3055,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Pragma", _Pragma); + array[arrayIndex] = new KeyValuePair("Pragma", _Pragma); ++arrayIndex; } @@ -3065,7 +3066,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Trailer", _Trailer); + array[arrayIndex] = new KeyValuePair("Trailer", _Trailer); ++arrayIndex; } @@ -3076,7 +3077,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Transfer-Encoding", _TransferEncoding); + array[arrayIndex] = new KeyValuePair("Transfer-Encoding", _TransferEncoding); ++arrayIndex; } @@ -3087,7 +3088,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Upgrade", _Upgrade); + array[arrayIndex] = new KeyValuePair("Upgrade", _Upgrade); ++arrayIndex; } @@ -3098,7 +3099,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Via", _Via); + array[arrayIndex] = new KeyValuePair("Via", _Via); ++arrayIndex; } @@ -3109,7 +3110,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Warning", _Warning); + array[arrayIndex] = new KeyValuePair("Warning", _Warning); ++arrayIndex; } @@ -3120,7 +3121,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Allow", _Allow); + array[arrayIndex] = new KeyValuePair("Allow", _Allow); ++arrayIndex; } @@ -3131,7 +3132,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Content-Length", _ContentLength); + array[arrayIndex] = new KeyValuePair("Content-Length", _ContentLength); ++arrayIndex; } @@ -3142,7 +3143,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Content-Type", _ContentType); + array[arrayIndex] = new KeyValuePair("Content-Type", _ContentType); ++arrayIndex; } @@ -3153,7 +3154,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Content-Encoding", _ContentEncoding); + array[arrayIndex] = new KeyValuePair("Content-Encoding", _ContentEncoding); ++arrayIndex; } @@ -3164,7 +3165,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Content-Language", _ContentLanguage); + array[arrayIndex] = new KeyValuePair("Content-Language", _ContentLanguage); ++arrayIndex; } @@ -3175,7 +3176,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Content-Location", _ContentLocation); + array[arrayIndex] = new KeyValuePair("Content-Location", _ContentLocation); ++arrayIndex; } @@ -3186,7 +3187,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Content-MD5", _ContentMD5); + array[arrayIndex] = new KeyValuePair("Content-MD5", _ContentMD5); ++arrayIndex; } @@ -3197,7 +3198,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Content-Range", _ContentRange); + array[arrayIndex] = new KeyValuePair("Content-Range", _ContentRange); ++arrayIndex; } @@ -3208,7 +3209,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Expires", _Expires); + array[arrayIndex] = new KeyValuePair("Expires", _Expires); ++arrayIndex; } @@ -3219,7 +3220,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Last-Modified", _LastModified); + array[arrayIndex] = new KeyValuePair("Last-Modified", _LastModified); ++arrayIndex; } @@ -3230,7 +3231,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Accept", _Accept); + array[arrayIndex] = new KeyValuePair("Accept", _Accept); ++arrayIndex; } @@ -3241,7 +3242,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Accept-Charset", _AcceptCharset); + array[arrayIndex] = new KeyValuePair("Accept-Charset", _AcceptCharset); ++arrayIndex; } @@ -3252,7 +3253,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Accept-Encoding", _AcceptEncoding); + array[arrayIndex] = new KeyValuePair("Accept-Encoding", _AcceptEncoding); ++arrayIndex; } @@ -3263,7 +3264,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Accept-Language", _AcceptLanguage); + array[arrayIndex] = new KeyValuePair("Accept-Language", _AcceptLanguage); ++arrayIndex; } @@ -3274,7 +3275,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Authorization", _Authorization); + array[arrayIndex] = new KeyValuePair("Authorization", _Authorization); ++arrayIndex; } @@ -3285,7 +3286,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Cookie", _Cookie); + array[arrayIndex] = new KeyValuePair("Cookie", _Cookie); ++arrayIndex; } @@ -3296,7 +3297,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Expect", _Expect); + array[arrayIndex] = new KeyValuePair("Expect", _Expect); ++arrayIndex; } @@ -3307,7 +3308,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("From", _From); + array[arrayIndex] = new KeyValuePair("From", _From); ++arrayIndex; } @@ -3318,7 +3319,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Host", _Host); + array[arrayIndex] = new KeyValuePair("Host", _Host); ++arrayIndex; } @@ -3329,7 +3330,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("If-Match", _IfMatch); + array[arrayIndex] = new KeyValuePair("If-Match", _IfMatch); ++arrayIndex; } @@ -3340,7 +3341,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("If-Modified-Since", _IfModifiedSince); + array[arrayIndex] = new KeyValuePair("If-Modified-Since", _IfModifiedSince); ++arrayIndex; } @@ -3351,7 +3352,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("If-None-Match", _IfNoneMatch); + array[arrayIndex] = new KeyValuePair("If-None-Match", _IfNoneMatch); ++arrayIndex; } @@ -3362,7 +3363,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("If-Range", _IfRange); + array[arrayIndex] = new KeyValuePair("If-Range", _IfRange); ++arrayIndex; } @@ -3373,7 +3374,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("If-Unmodified-Since", _IfUnmodifiedSince); + array[arrayIndex] = new KeyValuePair("If-Unmodified-Since", _IfUnmodifiedSince); ++arrayIndex; } @@ -3384,7 +3385,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Max-Forwards", _MaxForwards); + array[arrayIndex] = new KeyValuePair("Max-Forwards", _MaxForwards); ++arrayIndex; } @@ -3395,7 +3396,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Proxy-Authorization", _ProxyAuthorization); + array[arrayIndex] = new KeyValuePair("Proxy-Authorization", _ProxyAuthorization); ++arrayIndex; } @@ -3406,7 +3407,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Referer", _Referer); + array[arrayIndex] = new KeyValuePair("Referer", _Referer); ++arrayIndex; } @@ -3417,7 +3418,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Range", _Range); + array[arrayIndex] = new KeyValuePair("Range", _Range); ++arrayIndex; } @@ -3428,7 +3429,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("TE", _TE); + array[arrayIndex] = new KeyValuePair("TE", _TE); ++arrayIndex; } @@ -3439,7 +3440,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Translate", _Translate); + array[arrayIndex] = new KeyValuePair("Translate", _Translate); ++arrayIndex; } @@ -3450,11 +3451,11 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("User-Agent", _UserAgent); + array[arrayIndex] = new KeyValuePair("User-Agent", _UserAgent); ++arrayIndex; } - ((ICollection>)MaybeUnknown)?.CopyTo(array, arrayIndex); + ((ICollection>)MaybeUnknown)?.CopyTo(array, arrayIndex); } public unsafe void Append(byte[] keyBytes, int keyOffset, int keyLength, string value) @@ -4105,8 +4106,9 @@ namespace Microsoft.AspNet.Server.Kestrel.Http break; }} var key = System.Text.Encoding.ASCII.GetString(keyBytes, keyOffset, keyLength); - string[] existing; - Unknown[key] = Unknown.TryGetValue(key, out existing) ? AppendValue(existing, value) : new[] {value}; + StringValues existing; + Unknown.TryGetValue(key, out existing); + Unknown[key] = AppendValue(existing, value); } public partial struct Enumerator @@ -4246,7 +4248,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state0: if (((_bits & 1L) != 0)) { - _current = new KeyValuePair("Cache-Control", _collection._CacheControl); + _current = new KeyValuePair("Cache-Control", _collection._CacheControl); _state = 1; return true; } @@ -4254,7 +4256,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state1: if (((_bits & 2L) != 0)) { - _current = new KeyValuePair("Connection", _collection._Connection); + _current = new KeyValuePair("Connection", _collection._Connection); _state = 2; return true; } @@ -4262,7 +4264,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state2: if (((_bits & 4L) != 0)) { - _current = new KeyValuePair("Date", _collection._Date); + _current = new KeyValuePair("Date", _collection._Date); _state = 3; return true; } @@ -4270,7 +4272,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state3: if (((_bits & 8L) != 0)) { - _current = new KeyValuePair("Keep-Alive", _collection._KeepAlive); + _current = new KeyValuePair("Keep-Alive", _collection._KeepAlive); _state = 4; return true; } @@ -4278,7 +4280,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state4: if (((_bits & 16L) != 0)) { - _current = new KeyValuePair("Pragma", _collection._Pragma); + _current = new KeyValuePair("Pragma", _collection._Pragma); _state = 5; return true; } @@ -4286,7 +4288,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state5: if (((_bits & 32L) != 0)) { - _current = new KeyValuePair("Trailer", _collection._Trailer); + _current = new KeyValuePair("Trailer", _collection._Trailer); _state = 6; return true; } @@ -4294,7 +4296,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state6: if (((_bits & 64L) != 0)) { - _current = new KeyValuePair("Transfer-Encoding", _collection._TransferEncoding); + _current = new KeyValuePair("Transfer-Encoding", _collection._TransferEncoding); _state = 7; return true; } @@ -4302,7 +4304,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state7: if (((_bits & 128L) != 0)) { - _current = new KeyValuePair("Upgrade", _collection._Upgrade); + _current = new KeyValuePair("Upgrade", _collection._Upgrade); _state = 8; return true; } @@ -4310,7 +4312,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state8: if (((_bits & 256L) != 0)) { - _current = new KeyValuePair("Via", _collection._Via); + _current = new KeyValuePair("Via", _collection._Via); _state = 9; return true; } @@ -4318,7 +4320,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state9: if (((_bits & 512L) != 0)) { - _current = new KeyValuePair("Warning", _collection._Warning); + _current = new KeyValuePair("Warning", _collection._Warning); _state = 10; return true; } @@ -4326,7 +4328,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state10: if (((_bits & 1024L) != 0)) { - _current = new KeyValuePair("Allow", _collection._Allow); + _current = new KeyValuePair("Allow", _collection._Allow); _state = 11; return true; } @@ -4334,7 +4336,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state11: if (((_bits & 2048L) != 0)) { - _current = new KeyValuePair("Content-Length", _collection._ContentLength); + _current = new KeyValuePair("Content-Length", _collection._ContentLength); _state = 12; return true; } @@ -4342,7 +4344,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state12: if (((_bits & 4096L) != 0)) { - _current = new KeyValuePair("Content-Type", _collection._ContentType); + _current = new KeyValuePair("Content-Type", _collection._ContentType); _state = 13; return true; } @@ -4350,7 +4352,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state13: if (((_bits & 8192L) != 0)) { - _current = new KeyValuePair("Content-Encoding", _collection._ContentEncoding); + _current = new KeyValuePair("Content-Encoding", _collection._ContentEncoding); _state = 14; return true; } @@ -4358,7 +4360,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state14: if (((_bits & 16384L) != 0)) { - _current = new KeyValuePair("Content-Language", _collection._ContentLanguage); + _current = new KeyValuePair("Content-Language", _collection._ContentLanguage); _state = 15; return true; } @@ -4366,7 +4368,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state15: if (((_bits & 32768L) != 0)) { - _current = new KeyValuePair("Content-Location", _collection._ContentLocation); + _current = new KeyValuePair("Content-Location", _collection._ContentLocation); _state = 16; return true; } @@ -4374,7 +4376,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state16: if (((_bits & 65536L) != 0)) { - _current = new KeyValuePair("Content-MD5", _collection._ContentMD5); + _current = new KeyValuePair("Content-MD5", _collection._ContentMD5); _state = 17; return true; } @@ -4382,7 +4384,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state17: if (((_bits & 131072L) != 0)) { - _current = new KeyValuePair("Content-Range", _collection._ContentRange); + _current = new KeyValuePair("Content-Range", _collection._ContentRange); _state = 18; return true; } @@ -4390,7 +4392,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state18: if (((_bits & 262144L) != 0)) { - _current = new KeyValuePair("Expires", _collection._Expires); + _current = new KeyValuePair("Expires", _collection._Expires); _state = 19; return true; } @@ -4398,7 +4400,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state19: if (((_bits & 524288L) != 0)) { - _current = new KeyValuePair("Last-Modified", _collection._LastModified); + _current = new KeyValuePair("Last-Modified", _collection._LastModified); _state = 20; return true; } @@ -4406,7 +4408,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state20: if (((_bits & 1048576L) != 0)) { - _current = new KeyValuePair("Accept", _collection._Accept); + _current = new KeyValuePair("Accept", _collection._Accept); _state = 21; return true; } @@ -4414,7 +4416,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state21: if (((_bits & 2097152L) != 0)) { - _current = new KeyValuePair("Accept-Charset", _collection._AcceptCharset); + _current = new KeyValuePair("Accept-Charset", _collection._AcceptCharset); _state = 22; return true; } @@ -4422,7 +4424,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state22: if (((_bits & 4194304L) != 0)) { - _current = new KeyValuePair("Accept-Encoding", _collection._AcceptEncoding); + _current = new KeyValuePair("Accept-Encoding", _collection._AcceptEncoding); _state = 23; return true; } @@ -4430,7 +4432,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state23: if (((_bits & 8388608L) != 0)) { - _current = new KeyValuePair("Accept-Language", _collection._AcceptLanguage); + _current = new KeyValuePair("Accept-Language", _collection._AcceptLanguage); _state = 24; return true; } @@ -4438,7 +4440,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state24: if (((_bits & 16777216L) != 0)) { - _current = new KeyValuePair("Authorization", _collection._Authorization); + _current = new KeyValuePair("Authorization", _collection._Authorization); _state = 25; return true; } @@ -4446,7 +4448,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state25: if (((_bits & 33554432L) != 0)) { - _current = new KeyValuePair("Cookie", _collection._Cookie); + _current = new KeyValuePair("Cookie", _collection._Cookie); _state = 26; return true; } @@ -4454,7 +4456,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state26: if (((_bits & 67108864L) != 0)) { - _current = new KeyValuePair("Expect", _collection._Expect); + _current = new KeyValuePair("Expect", _collection._Expect); _state = 27; return true; } @@ -4462,7 +4464,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state27: if (((_bits & 134217728L) != 0)) { - _current = new KeyValuePair("From", _collection._From); + _current = new KeyValuePair("From", _collection._From); _state = 28; return true; } @@ -4470,7 +4472,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state28: if (((_bits & 268435456L) != 0)) { - _current = new KeyValuePair("Host", _collection._Host); + _current = new KeyValuePair("Host", _collection._Host); _state = 29; return true; } @@ -4478,7 +4480,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state29: if (((_bits & 536870912L) != 0)) { - _current = new KeyValuePair("If-Match", _collection._IfMatch); + _current = new KeyValuePair("If-Match", _collection._IfMatch); _state = 30; return true; } @@ -4486,7 +4488,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state30: if (((_bits & 1073741824L) != 0)) { - _current = new KeyValuePair("If-Modified-Since", _collection._IfModifiedSince); + _current = new KeyValuePair("If-Modified-Since", _collection._IfModifiedSince); _state = 31; return true; } @@ -4494,7 +4496,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state31: if (((_bits & 2147483648L) != 0)) { - _current = new KeyValuePair("If-None-Match", _collection._IfNoneMatch); + _current = new KeyValuePair("If-None-Match", _collection._IfNoneMatch); _state = 32; return true; } @@ -4502,7 +4504,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state32: if (((_bits & 4294967296L) != 0)) { - _current = new KeyValuePair("If-Range", _collection._IfRange); + _current = new KeyValuePair("If-Range", _collection._IfRange); _state = 33; return true; } @@ -4510,7 +4512,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state33: if (((_bits & 8589934592L) != 0)) { - _current = new KeyValuePair("If-Unmodified-Since", _collection._IfUnmodifiedSince); + _current = new KeyValuePair("If-Unmodified-Since", _collection._IfUnmodifiedSince); _state = 34; return true; } @@ -4518,7 +4520,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state34: if (((_bits & 17179869184L) != 0)) { - _current = new KeyValuePair("Max-Forwards", _collection._MaxForwards); + _current = new KeyValuePair("Max-Forwards", _collection._MaxForwards); _state = 35; return true; } @@ -4526,7 +4528,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state35: if (((_bits & 34359738368L) != 0)) { - _current = new KeyValuePair("Proxy-Authorization", _collection._ProxyAuthorization); + _current = new KeyValuePair("Proxy-Authorization", _collection._ProxyAuthorization); _state = 36; return true; } @@ -4534,7 +4536,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state36: if (((_bits & 68719476736L) != 0)) { - _current = new KeyValuePair("Referer", _collection._Referer); + _current = new KeyValuePair("Referer", _collection._Referer); _state = 37; return true; } @@ -4542,7 +4544,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state37: if (((_bits & 137438953472L) != 0)) { - _current = new KeyValuePair("Range", _collection._Range); + _current = new KeyValuePair("Range", _collection._Range); _state = 38; return true; } @@ -4550,7 +4552,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state38: if (((_bits & 274877906944L) != 0)) { - _current = new KeyValuePair("TE", _collection._TE); + _current = new KeyValuePair("TE", _collection._TE); _state = 39; return true; } @@ -4558,7 +4560,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state39: if (((_bits & 549755813888L) != 0)) { - _current = new KeyValuePair("Translate", _collection._Translate); + _current = new KeyValuePair("Translate", _collection._Translate); _state = 40; return true; } @@ -4566,7 +4568,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state40: if (((_bits & 1099511627776L) != 0)) { - _current = new KeyValuePair("User-Agent", _collection._UserAgent); + _current = new KeyValuePair("User-Agent", _collection._UserAgent); _state = 41; return true; } @@ -4574,7 +4576,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state_default: if (!_hasUnknown || !_unknownEnumerator.MoveNext()) { - _current = default(KeyValuePair); + _current = default(KeyValuePair); return false; } _current = _unknownEnumerator.Current; @@ -4587,36 +4589,36 @@ namespace Microsoft.AspNet.Server.Kestrel.Http { long _bits = 0; - string[] _CacheControl; - string[] _Connection; - string[] _Date; - string[] _KeepAlive; - string[] _Pragma; - string[] _Trailer; - string[] _TransferEncoding; - string[] _Upgrade; - string[] _Via; - string[] _Warning; - string[] _Allow; - string[] _ContentLength; - string[] _ContentType; - string[] _ContentEncoding; - string[] _ContentLanguage; - string[] _ContentLocation; - string[] _ContentMD5; - string[] _ContentRange; - string[] _Expires; - string[] _LastModified; - string[] _AcceptRanges; - string[] _Age; - string[] _ETag; - string[] _Location; - string[] _ProxyAutheticate; - string[] _RetryAfter; - string[] _Server; - string[] _SetCookie; - string[] _Vary; - string[] _WWWAuthenticate; + StringValues _CacheControl; + StringValues _Connection; + StringValues _Date; + StringValues _KeepAlive; + StringValues _Pragma; + StringValues _Trailer; + StringValues _TransferEncoding; + StringValues _Upgrade; + StringValues _Via; + StringValues _Warning; + StringValues _Allow; + StringValues _ContentLength; + StringValues _ContentType; + StringValues _ContentEncoding; + StringValues _ContentLanguage; + StringValues _ContentLocation; + StringValues _ContentMD5; + StringValues _ContentRange; + StringValues _Expires; + StringValues _LastModified; + StringValues _AcceptRanges; + StringValues _Age; + StringValues _ETag; + StringValues _Location; + StringValues _ProxyAutheticate; + StringValues _RetryAfter; + StringValues _Server; + StringValues _SetCookie; + StringValues _Vary; + StringValues _WWWAuthenticate; protected override int GetCountFast() { @@ -4775,7 +4777,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http return count; } - protected override string[] GetValueFast(string key) + protected override StringValues GetValueFast(string key) { switch(key.Length) { @@ -5198,7 +5200,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http return MaybeUnknown[key]; } - protected override bool TryGetValueFast(string key, out string[] value) + protected override bool TryGetValueFast(string key, out StringValues value) { switch(key.Length) { @@ -5213,7 +5215,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -5227,7 +5229,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -5241,7 +5243,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -5255,7 +5257,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -5273,7 +5275,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -5287,7 +5289,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -5301,7 +5303,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -5319,7 +5321,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -5333,7 +5335,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -5347,7 +5349,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -5365,7 +5367,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -5379,7 +5381,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -5397,7 +5399,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -5411,7 +5413,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -5425,7 +5427,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -5439,7 +5441,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -5457,7 +5459,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -5471,7 +5473,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -5489,7 +5491,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -5503,7 +5505,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -5521,7 +5523,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -5539,7 +5541,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -5557,7 +5559,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -5575,7 +5577,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -5589,7 +5591,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -5603,7 +5605,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -5617,7 +5619,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -5635,7 +5637,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -5649,7 +5651,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } @@ -5667,18 +5669,18 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } else { - value = null; + value = StringValues.Empty; return false; } } } break; } - value = null; + value = StringValues.Empty; return MaybeUnknown?.TryGetValue(key, out value) ?? false; } - protected override void SetValueFast(string key, string[] value) + protected override void SetValueFast(string key, StringValues value) { switch(key.Length) { @@ -5947,7 +5949,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http Unknown[key] = value; } - protected override void AddValueFast(string key, string[] value) + protected override void AddValueFast(string key, StringValues value) { switch(key.Length) { @@ -6791,7 +6793,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http MaybeUnknown?.Clear(); } - protected override void CopyToFast(KeyValuePair[] array, int arrayIndex) + protected override void CopyToFast(KeyValuePair[] array, int arrayIndex) { if (arrayIndex < 0) { @@ -6806,7 +6808,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Cache-Control", _CacheControl); + array[arrayIndex] = new KeyValuePair("Cache-Control", _CacheControl); ++arrayIndex; } @@ -6817,7 +6819,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Connection", _Connection); + array[arrayIndex] = new KeyValuePair("Connection", _Connection); ++arrayIndex; } @@ -6828,7 +6830,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Date", _Date); + array[arrayIndex] = new KeyValuePair("Date", _Date); ++arrayIndex; } @@ -6839,7 +6841,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Keep-Alive", _KeepAlive); + array[arrayIndex] = new KeyValuePair("Keep-Alive", _KeepAlive); ++arrayIndex; } @@ -6850,7 +6852,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Pragma", _Pragma); + array[arrayIndex] = new KeyValuePair("Pragma", _Pragma); ++arrayIndex; } @@ -6861,7 +6863,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Trailer", _Trailer); + array[arrayIndex] = new KeyValuePair("Trailer", _Trailer); ++arrayIndex; } @@ -6872,7 +6874,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Transfer-Encoding", _TransferEncoding); + array[arrayIndex] = new KeyValuePair("Transfer-Encoding", _TransferEncoding); ++arrayIndex; } @@ -6883,7 +6885,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Upgrade", _Upgrade); + array[arrayIndex] = new KeyValuePair("Upgrade", _Upgrade); ++arrayIndex; } @@ -6894,7 +6896,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Via", _Via); + array[arrayIndex] = new KeyValuePair("Via", _Via); ++arrayIndex; } @@ -6905,7 +6907,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Warning", _Warning); + array[arrayIndex] = new KeyValuePair("Warning", _Warning); ++arrayIndex; } @@ -6916,7 +6918,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Allow", _Allow); + array[arrayIndex] = new KeyValuePair("Allow", _Allow); ++arrayIndex; } @@ -6927,7 +6929,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Content-Length", _ContentLength); + array[arrayIndex] = new KeyValuePair("Content-Length", _ContentLength); ++arrayIndex; } @@ -6938,7 +6940,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Content-Type", _ContentType); + array[arrayIndex] = new KeyValuePair("Content-Type", _ContentType); ++arrayIndex; } @@ -6949,7 +6951,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Content-Encoding", _ContentEncoding); + array[arrayIndex] = new KeyValuePair("Content-Encoding", _ContentEncoding); ++arrayIndex; } @@ -6960,7 +6962,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Content-Language", _ContentLanguage); + array[arrayIndex] = new KeyValuePair("Content-Language", _ContentLanguage); ++arrayIndex; } @@ -6971,7 +6973,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Content-Location", _ContentLocation); + array[arrayIndex] = new KeyValuePair("Content-Location", _ContentLocation); ++arrayIndex; } @@ -6982,7 +6984,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Content-MD5", _ContentMD5); + array[arrayIndex] = new KeyValuePair("Content-MD5", _ContentMD5); ++arrayIndex; } @@ -6993,7 +6995,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Content-Range", _ContentRange); + array[arrayIndex] = new KeyValuePair("Content-Range", _ContentRange); ++arrayIndex; } @@ -7004,7 +7006,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Expires", _Expires); + array[arrayIndex] = new KeyValuePair("Expires", _Expires); ++arrayIndex; } @@ -7015,7 +7017,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Last-Modified", _LastModified); + array[arrayIndex] = new KeyValuePair("Last-Modified", _LastModified); ++arrayIndex; } @@ -7026,7 +7028,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Accept-Ranges", _AcceptRanges); + array[arrayIndex] = new KeyValuePair("Accept-Ranges", _AcceptRanges); ++arrayIndex; } @@ -7037,7 +7039,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Age", _Age); + array[arrayIndex] = new KeyValuePair("Age", _Age); ++arrayIndex; } @@ -7048,7 +7050,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("ETag", _ETag); + array[arrayIndex] = new KeyValuePair("ETag", _ETag); ++arrayIndex; } @@ -7059,7 +7061,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Location", _Location); + array[arrayIndex] = new KeyValuePair("Location", _Location); ++arrayIndex; } @@ -7070,7 +7072,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Proxy-Autheticate", _ProxyAutheticate); + array[arrayIndex] = new KeyValuePair("Proxy-Autheticate", _ProxyAutheticate); ++arrayIndex; } @@ -7081,7 +7083,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Retry-After", _RetryAfter); + array[arrayIndex] = new KeyValuePair("Retry-After", _RetryAfter); ++arrayIndex; } @@ -7092,7 +7094,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Server", _Server); + array[arrayIndex] = new KeyValuePair("Server", _Server); ++arrayIndex; } @@ -7103,7 +7105,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Set-Cookie", _SetCookie); + array[arrayIndex] = new KeyValuePair("Set-Cookie", _SetCookie); ++arrayIndex; } @@ -7114,7 +7116,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("Vary", _Vary); + array[arrayIndex] = new KeyValuePair("Vary", _Vary); ++arrayIndex; } @@ -7125,11 +7127,11 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); } - array[arrayIndex] = new KeyValuePair("WWW-Authenticate", _WWWAuthenticate); + array[arrayIndex] = new KeyValuePair("WWW-Authenticate", _WWWAuthenticate); ++arrayIndex; } - ((ICollection>)MaybeUnknown)?.CopyTo(array, arrayIndex); + ((ICollection>)MaybeUnknown)?.CopyTo(array, arrayIndex); } public unsafe void Append(byte[] keyBytes, int keyOffset, int keyLength, string value) @@ -7610,8 +7612,9 @@ namespace Microsoft.AspNet.Server.Kestrel.Http break; }} var key = System.Text.Encoding.ASCII.GetString(keyBytes, keyOffset, keyLength); - string[] existing; - Unknown[key] = Unknown.TryGetValue(key, out existing) ? AppendValue(existing, value) : new[] {value}; + StringValues existing; + Unknown.TryGetValue(key, out existing); + Unknown[key] = AppendValue(existing, value); } public partial struct Enumerator @@ -7718,7 +7721,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state0: if (((_bits & 1L) != 0)) { - _current = new KeyValuePair("Cache-Control", _collection._CacheControl); + _current = new KeyValuePair("Cache-Control", _collection._CacheControl); _state = 1; return true; } @@ -7726,7 +7729,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state1: if (((_bits & 2L) != 0)) { - _current = new KeyValuePair("Connection", _collection._Connection); + _current = new KeyValuePair("Connection", _collection._Connection); _state = 2; return true; } @@ -7734,7 +7737,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state2: if (((_bits & 4L) != 0)) { - _current = new KeyValuePair("Date", _collection._Date); + _current = new KeyValuePair("Date", _collection._Date); _state = 3; return true; } @@ -7742,7 +7745,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state3: if (((_bits & 8L) != 0)) { - _current = new KeyValuePair("Keep-Alive", _collection._KeepAlive); + _current = new KeyValuePair("Keep-Alive", _collection._KeepAlive); _state = 4; return true; } @@ -7750,7 +7753,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state4: if (((_bits & 16L) != 0)) { - _current = new KeyValuePair("Pragma", _collection._Pragma); + _current = new KeyValuePair("Pragma", _collection._Pragma); _state = 5; return true; } @@ -7758,7 +7761,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state5: if (((_bits & 32L) != 0)) { - _current = new KeyValuePair("Trailer", _collection._Trailer); + _current = new KeyValuePair("Trailer", _collection._Trailer); _state = 6; return true; } @@ -7766,7 +7769,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state6: if (((_bits & 64L) != 0)) { - _current = new KeyValuePair("Transfer-Encoding", _collection._TransferEncoding); + _current = new KeyValuePair("Transfer-Encoding", _collection._TransferEncoding); _state = 7; return true; } @@ -7774,7 +7777,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state7: if (((_bits & 128L) != 0)) { - _current = new KeyValuePair("Upgrade", _collection._Upgrade); + _current = new KeyValuePair("Upgrade", _collection._Upgrade); _state = 8; return true; } @@ -7782,7 +7785,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state8: if (((_bits & 256L) != 0)) { - _current = new KeyValuePair("Via", _collection._Via); + _current = new KeyValuePair("Via", _collection._Via); _state = 9; return true; } @@ -7790,7 +7793,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state9: if (((_bits & 512L) != 0)) { - _current = new KeyValuePair("Warning", _collection._Warning); + _current = new KeyValuePair("Warning", _collection._Warning); _state = 10; return true; } @@ -7798,7 +7801,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state10: if (((_bits & 1024L) != 0)) { - _current = new KeyValuePair("Allow", _collection._Allow); + _current = new KeyValuePair("Allow", _collection._Allow); _state = 11; return true; } @@ -7806,7 +7809,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state11: if (((_bits & 2048L) != 0)) { - _current = new KeyValuePair("Content-Length", _collection._ContentLength); + _current = new KeyValuePair("Content-Length", _collection._ContentLength); _state = 12; return true; } @@ -7814,7 +7817,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state12: if (((_bits & 4096L) != 0)) { - _current = new KeyValuePair("Content-Type", _collection._ContentType); + _current = new KeyValuePair("Content-Type", _collection._ContentType); _state = 13; return true; } @@ -7822,7 +7825,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state13: if (((_bits & 8192L) != 0)) { - _current = new KeyValuePair("Content-Encoding", _collection._ContentEncoding); + _current = new KeyValuePair("Content-Encoding", _collection._ContentEncoding); _state = 14; return true; } @@ -7830,7 +7833,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state14: if (((_bits & 16384L) != 0)) { - _current = new KeyValuePair("Content-Language", _collection._ContentLanguage); + _current = new KeyValuePair("Content-Language", _collection._ContentLanguage); _state = 15; return true; } @@ -7838,7 +7841,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state15: if (((_bits & 32768L) != 0)) { - _current = new KeyValuePair("Content-Location", _collection._ContentLocation); + _current = new KeyValuePair("Content-Location", _collection._ContentLocation); _state = 16; return true; } @@ -7846,7 +7849,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state16: if (((_bits & 65536L) != 0)) { - _current = new KeyValuePair("Content-MD5", _collection._ContentMD5); + _current = new KeyValuePair("Content-MD5", _collection._ContentMD5); _state = 17; return true; } @@ -7854,7 +7857,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state17: if (((_bits & 131072L) != 0)) { - _current = new KeyValuePair("Content-Range", _collection._ContentRange); + _current = new KeyValuePair("Content-Range", _collection._ContentRange); _state = 18; return true; } @@ -7862,7 +7865,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state18: if (((_bits & 262144L) != 0)) { - _current = new KeyValuePair("Expires", _collection._Expires); + _current = new KeyValuePair("Expires", _collection._Expires); _state = 19; return true; } @@ -7870,7 +7873,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state19: if (((_bits & 524288L) != 0)) { - _current = new KeyValuePair("Last-Modified", _collection._LastModified); + _current = new KeyValuePair("Last-Modified", _collection._LastModified); _state = 20; return true; } @@ -7878,7 +7881,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state20: if (((_bits & 1048576L) != 0)) { - _current = new KeyValuePair("Accept-Ranges", _collection._AcceptRanges); + _current = new KeyValuePair("Accept-Ranges", _collection._AcceptRanges); _state = 21; return true; } @@ -7886,7 +7889,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state21: if (((_bits & 2097152L) != 0)) { - _current = new KeyValuePair("Age", _collection._Age); + _current = new KeyValuePair("Age", _collection._Age); _state = 22; return true; } @@ -7894,7 +7897,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state22: if (((_bits & 4194304L) != 0)) { - _current = new KeyValuePair("ETag", _collection._ETag); + _current = new KeyValuePair("ETag", _collection._ETag); _state = 23; return true; } @@ -7902,7 +7905,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state23: if (((_bits & 8388608L) != 0)) { - _current = new KeyValuePair("Location", _collection._Location); + _current = new KeyValuePair("Location", _collection._Location); _state = 24; return true; } @@ -7910,7 +7913,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state24: if (((_bits & 16777216L) != 0)) { - _current = new KeyValuePair("Proxy-Autheticate", _collection._ProxyAutheticate); + _current = new KeyValuePair("Proxy-Autheticate", _collection._ProxyAutheticate); _state = 25; return true; } @@ -7918,7 +7921,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state25: if (((_bits & 33554432L) != 0)) { - _current = new KeyValuePair("Retry-After", _collection._RetryAfter); + _current = new KeyValuePair("Retry-After", _collection._RetryAfter); _state = 26; return true; } @@ -7926,7 +7929,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state26: if (((_bits & 67108864L) != 0)) { - _current = new KeyValuePair("Server", _collection._Server); + _current = new KeyValuePair("Server", _collection._Server); _state = 27; return true; } @@ -7934,7 +7937,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state27: if (((_bits & 134217728L) != 0)) { - _current = new KeyValuePair("Set-Cookie", _collection._SetCookie); + _current = new KeyValuePair("Set-Cookie", _collection._SetCookie); _state = 28; return true; } @@ -7942,7 +7945,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state28: if (((_bits & 268435456L) != 0)) { - _current = new KeyValuePair("Vary", _collection._Vary); + _current = new KeyValuePair("Vary", _collection._Vary); _state = 29; return true; } @@ -7950,7 +7953,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state29: if (((_bits & 536870912L) != 0)) { - _current = new KeyValuePair("WWW-Authenticate", _collection._WWWAuthenticate); + _current = new KeyValuePair("WWW-Authenticate", _collection._WWWAuthenticate); _state = 30; return true; } @@ -7958,7 +7961,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state_default: if (!_hasUnknown || !_unknownEnumerator.MoveNext()) { - _current = default(KeyValuePair); + _current = default(KeyValuePair); return false; } _current = _unknownEnumerator.Current; diff --git a/src/Microsoft.AspNet.Server.Kestrel/Http/FrameHeaders.cs b/src/Microsoft.AspNet.Server.Kestrel/Http/FrameHeaders.cs index 9cd8d90488..c8a6d7cd44 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Http/FrameHeaders.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Http/FrameHeaders.cs @@ -2,36 +2,34 @@ using System.Collections; using System.Collections.Generic; using System.Linq; +using Microsoft.Framework.Primitives; namespace Microsoft.AspNet.Server.Kestrel.Http { - public abstract class FrameHeaders : IDictionary + public abstract class FrameHeaders : IDictionary { - protected Dictionary MaybeUnknown; + protected Dictionary MaybeUnknown; - protected Dictionary Unknown => MaybeUnknown ?? (MaybeUnknown = new Dictionary(StringComparer.OrdinalIgnoreCase)); + protected Dictionary Unknown => MaybeUnknown ?? (MaybeUnknown = new Dictionary(StringComparer.OrdinalIgnoreCase)); - protected static string[] AppendValue(string[] existing, string append) + protected static StringValues AppendValue(StringValues existing, string append) { - var appended = new string[existing.Length + 1]; - Array.Copy(existing, appended, existing.Length); - appended[existing.Length] = append; - return appended; + return StringValues.Concat(existing, append); } protected virtual int GetCountFast() { throw new NotImplementedException(); } - protected virtual string[] GetValueFast(string key) + protected virtual StringValues GetValueFast(string key) { throw new NotImplementedException(); } - protected virtual bool TryGetValueFast(string key, out string[] value) + protected virtual bool TryGetValueFast(string key, out StringValues value) { throw new NotImplementedException(); } - protected virtual void SetValueFast(string key, string[] value) + protected virtual void SetValueFast(string key, StringValues value) { throw new NotImplementedException(); } - protected virtual void AddValueFast(string key, string[] value) + protected virtual void AddValueFast(string key, StringValues value) { throw new NotImplementedException(); } protected virtual bool RemoveFast(string key) @@ -40,14 +38,14 @@ namespace Microsoft.AspNet.Server.Kestrel.Http protected virtual void ClearFast() { throw new NotImplementedException(); } - protected virtual void CopyToFast(KeyValuePair[] array, int arrayIndex) + protected virtual void CopyToFast(KeyValuePair[] array, int arrayIndex) { throw new NotImplementedException(); } - protected virtual IEnumerator> GetEnumeratorFast() + protected virtual IEnumerator> GetEnumeratorFast() { throw new NotImplementedException(); } - string[] IDictionary.this[string key] + StringValues IDictionary.this[string key] { get { @@ -60,44 +58,44 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } } - int ICollection>.Count => GetCountFast(); + int ICollection>.Count => GetCountFast(); - bool ICollection>.IsReadOnly => false; + bool ICollection>.IsReadOnly => false; - ICollection IDictionary.Keys => ((IDictionary)this).Select(x => x.Key).ToList(); + ICollection IDictionary.Keys => ((IDictionary)this).Select(x => x.Key).ToList(); - ICollection IDictionary.Values => ((IDictionary)this).Select(x => x.Value).ToList(); + ICollection IDictionary.Values => ((IDictionary)this).Select(x => x.Value).ToList(); - void ICollection>.Add(KeyValuePair item) + void ICollection>.Add(KeyValuePair item) { AddValueFast(item.Key, item.Value); } - void IDictionary.Add(string key, string[] value) + void IDictionary.Add(string key, StringValues value) { AddValueFast(key, value); } - void ICollection>.Clear() + void ICollection>.Clear() { ClearFast(); } - bool ICollection>.Contains(KeyValuePair item) + bool ICollection>.Contains(KeyValuePair item) { - string[] value; + StringValues value; return TryGetValueFast(item.Key, out value) && object.Equals(value, item.Value); } - bool IDictionary.ContainsKey(string key) + bool IDictionary.ContainsKey(string key) { - string[] value; + StringValues value; return TryGetValueFast(key, out value); } - void ICollection>.CopyTo(KeyValuePair[] array, int arrayIndex) + void ICollection>.CopyTo(KeyValuePair[] array, int arrayIndex) { CopyToFast(array, arrayIndex); } @@ -107,26 +105,26 @@ namespace Microsoft.AspNet.Server.Kestrel.Http return GetEnumeratorFast(); } - IEnumerator> IEnumerable>.GetEnumerator() + IEnumerator> IEnumerable>.GetEnumerator() { return GetEnumeratorFast(); } - bool ICollection>.Remove(KeyValuePair item) + bool ICollection>.Remove(KeyValuePair item) { - string[] value; + StringValues value; return TryGetValueFast(item.Key, out value) && object.Equals(value, item.Value) && RemoveFast(item.Key); } - bool IDictionary.Remove(string key) + bool IDictionary.Remove(string key) { return RemoveFast(key); } - bool IDictionary.TryGetValue(string key, out string[] value) + bool IDictionary.TryGetValue(string key, out StringValues value) { return TryGetValueFast(key, out value); } @@ -139,33 +137,33 @@ namespace Microsoft.AspNet.Server.Kestrel.Http return new Enumerator(this); } - protected override IEnumerator> GetEnumeratorFast() + protected override IEnumerator> GetEnumeratorFast() { return GetEnumerator(); } - public partial struct Enumerator : IEnumerator> + public partial struct Enumerator : IEnumerator> { FrameRequestHeaders _collection; long _bits; int _state; - KeyValuePair _current; + KeyValuePair _current; bool _hasUnknown; - Dictionary.Enumerator _unknownEnumerator; + Dictionary.Enumerator _unknownEnumerator; internal Enumerator(FrameRequestHeaders collection) { _collection = collection; _bits = collection._bits; _state = 0; - _current = default(KeyValuePair); + _current = default(KeyValuePair); _hasUnknown = collection.MaybeUnknown != null; _unknownEnumerator = _hasUnknown ? collection.MaybeUnknown.GetEnumerator() - : default(Dictionary.Enumerator); + : default(Dictionary.Enumerator); } - public KeyValuePair Current => _current; + public KeyValuePair Current => _current; object IEnumerator.Current => _current; @@ -187,33 +185,33 @@ namespace Microsoft.AspNet.Server.Kestrel.Http return new Enumerator(this); } - protected override IEnumerator> GetEnumeratorFast() + protected override IEnumerator> GetEnumeratorFast() { return GetEnumerator(); } - public partial struct Enumerator : IEnumerator> + public partial struct Enumerator : IEnumerator> { FrameResponseHeaders _collection; long _bits; int _state; - KeyValuePair _current; + KeyValuePair _current; bool _hasUnknown; - Dictionary.Enumerator _unknownEnumerator; + Dictionary.Enumerator _unknownEnumerator; internal Enumerator(FrameResponseHeaders collection) { _collection = collection; _bits = collection._bits; _state = 0; - _current = default(KeyValuePair); + _current = default(KeyValuePair); _hasUnknown = collection.MaybeUnknown != null; _unknownEnumerator = _hasUnknown ? collection.MaybeUnknown.GetEnumerator() - : default(Dictionary.Enumerator); + : default(Dictionary.Enumerator); } - public KeyValuePair Current => _current; + public KeyValuePair Current => _current; object IEnumerator.Current => _current; diff --git a/src/Microsoft.AspNet.Server.Kestrel/Http/MessageBody.cs b/src/Microsoft.AspNet.Server.Kestrel/Http/MessageBody.cs index b07f10c948..e7f788edbc 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Http/MessageBody.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Http/MessageBody.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using Microsoft.Framework.Primitives; namespace Microsoft.AspNet.Server.Kestrel.Http { @@ -28,7 +29,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http public static MessageBody For( string httpVersion, - IDictionary headers, + IDictionary headers, FrameContext context) { // see also http://tools.ietf.org/html/rfc2616#section-4.4 @@ -61,15 +62,15 @@ namespace Microsoft.AspNet.Server.Kestrel.Http return new ForRemainingData(context); } - public static bool TryGet(IDictionary headers, string name, out string value) + public static bool TryGet(IDictionary headers, string name, out string value) { - string[] values; + StringValues values; if (!headers.TryGetValue(name, out values) || values == null) { value = null; return false; } - var count = values.Length; + var count = values.Count; if (count == 0) { value = null; diff --git a/src/Microsoft.AspNet.Server.Kestrel/ServerRequest.cs b/src/Microsoft.AspNet.Server.Kestrel/ServerRequest.cs index 9d7d3dabe9..ebfa3f406c 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/ServerRequest.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/ServerRequest.cs @@ -8,6 +8,7 @@ using System.Linq; using System.Threading.Tasks; using Microsoft.AspNet.Http.Features; using Microsoft.AspNet.Server.Kestrel.Http; +using Microsoft.Framework.Primitives; namespace Microsoft.AspNet.Server.Kestrel { @@ -115,7 +116,7 @@ namespace Microsoft.AspNet.Server.Kestrel } } - IDictionary IHttpRequestFeature.Headers + IDictionary IHttpRequestFeature.Headers { get { @@ -167,7 +168,7 @@ namespace Microsoft.AspNet.Server.Kestrel } } - IDictionary IHttpResponseFeature.Headers + IDictionary IHttpResponseFeature.Headers { get { @@ -212,7 +213,7 @@ namespace Microsoft.AspNet.Server.Kestrel { get { - string[] values; + StringValues values; if (_frame.RequestHeaders.TryGetValue("Connection", out values)) { return values.Any(value => value.IndexOf("upgrade", StringComparison.OrdinalIgnoreCase) != -1); @@ -225,10 +226,10 @@ namespace Microsoft.AspNet.Server.Kestrel { _frame.StatusCode = 101; _frame.ReasonPhrase = "Switching Protocols"; - _frame.ResponseHeaders["Connection"] = new string[] { "Upgrade" }; + _frame.ResponseHeaders["Connection"] = "Upgrade"; if (!_frame.ResponseHeaders.ContainsKey("Upgrade")) { - string[] values; + StringValues values; if (_frame.RequestHeaders.TryGetValue("Upgrade", out values)) { _frame.ResponseHeaders["Upgrade"] = values; diff --git a/test/Microsoft.AspNet.Server.KestrelTests/FrameRequestHeadersTests.cs b/test/Microsoft.AspNet.Server.KestrelTests/FrameRequestHeadersTests.cs index f69b1c0746..7df87b5a7e 100644 --- a/test/Microsoft.AspNet.Server.KestrelTests/FrameRequestHeadersTests.cs +++ b/test/Microsoft.AspNet.Server.KestrelTests/FrameRequestHeadersTests.cs @@ -1,7 +1,7 @@ -using Microsoft.AspNet.Server.Kestrel.Http; -using System; +using System; using System.Collections.Generic; -using System.Linq; +using Microsoft.AspNet.Server.Kestrel.Http; +using Microsoft.Framework.Primitives; using Xunit; namespace Microsoft.AspNet.Server.KestrelTests @@ -11,7 +11,7 @@ namespace Microsoft.AspNet.Server.KestrelTests [Fact] public void InitialDictionaryIsEmpty() { - IDictionary headers = new FrameRequestHeaders(); + IDictionary headers = new FrameRequestHeaders(); Assert.Equal(0, headers.Count); Assert.False(headers.IsReadOnly); @@ -20,31 +20,31 @@ namespace Microsoft.AspNet.Server.KestrelTests [Fact] public void SettingUnknownHeadersWorks() { - IDictionary headers = new FrameRequestHeaders(); + IDictionary headers = new FrameRequestHeaders(); headers["custom"] = new[] { "value" }; Assert.NotNull(headers["custom"]); - Assert.Equal(1, headers["custom"].Length); + Assert.Equal(1, headers["custom"].Count); Assert.Equal("value", headers["custom"][0]); } [Fact] public void SettingKnownHeadersWorks() { - IDictionary headers = new FrameRequestHeaders(); + IDictionary headers = new FrameRequestHeaders(); headers["host"] = new[] { "value" }; Assert.NotNull(headers["host"]); - Assert.Equal(1, headers["host"].Length); + Assert.Equal(1, headers["host"].Count); Assert.Equal("value", headers["host"][0]); } [Fact] public void KnownAndCustomHeaderCountAddedTogether() { - IDictionary headers = new FrameRequestHeaders(); + IDictionary headers = new FrameRequestHeaders(); headers["host"] = new[] { "value" }; headers["custom"] = new[] { "value" }; @@ -55,9 +55,9 @@ namespace Microsoft.AspNet.Server.KestrelTests [Fact] public void TryGetValueWorksForKnownAndUnknownHeaders() { - IDictionary headers = new FrameRequestHeaders(); + IDictionary headers = new FrameRequestHeaders(); - string[] value; + StringValues value; Assert.False(headers.TryGetValue("host", out value)); Assert.False(headers.TryGetValue("custom", out value)); @@ -73,7 +73,7 @@ namespace Microsoft.AspNet.Server.KestrelTests [Fact] public void SameExceptionThrownForMissingKey() { - IDictionary headers = new FrameRequestHeaders(); + IDictionary headers = new FrameRequestHeaders(); Assert.Throws(() => headers["custom"]); Assert.Throws(() => headers["host"]); @@ -82,7 +82,7 @@ namespace Microsoft.AspNet.Server.KestrelTests [Fact] public void EntriesCanBeEnumerated() { - IDictionary headers = new FrameRequestHeaders(); + IDictionary headers = new FrameRequestHeaders(); var v1 = new[] { "localhost" }; var v2 = new[] { "value" }; headers["host"] = v1; @@ -90,8 +90,8 @@ namespace Microsoft.AspNet.Server.KestrelTests Assert.Equal( new[] { - new KeyValuePair("Host", v1), - new KeyValuePair("custom", v2), + new KeyValuePair("Host", v1), + new KeyValuePair("custom", v2), }, headers); } @@ -99,9 +99,9 @@ namespace Microsoft.AspNet.Server.KestrelTests [Fact] public void KeysAndValuesCanBeEnumerated() { - IDictionary headers = new FrameRequestHeaders(); - var v1 = new[] { "localhost" }; - var v2 = new[] { "value" }; + IDictionary headers = new FrameRequestHeaders(); + StringValues v1 = new[] { "localhost" }; + StringValues v2 = new[] { "value" }; headers["host"] = v1; headers["custom"] = v2; @@ -109,7 +109,7 @@ namespace Microsoft.AspNet.Server.KestrelTests new[] { "Host", "custom" }, headers.Keys); - Assert.Equal( + Assert.Equal( new[] { v1, v2 }, headers.Values); } @@ -118,11 +118,11 @@ namespace Microsoft.AspNet.Server.KestrelTests [Fact] public void ContainsAndContainsKeyWork() { - IDictionary headers = new FrameRequestHeaders(); - var kv1 = new KeyValuePair("host", new[] { "localhost" }); - var kv2 = new KeyValuePair("custom", new[] { "value" }); - var kv1b = new KeyValuePair("host", new[] { "localhost" }); - var kv2b = new KeyValuePair("custom", new[] { "value" }); + IDictionary headers = new FrameRequestHeaders(); + var kv1 = new KeyValuePair("host", new[] { "localhost" }); + var kv2 = new KeyValuePair("custom", new[] { "value" }); + var kv1b = new KeyValuePair("host", new[] { "localhost" }); + var kv2b = new KeyValuePair("custom", new[] { "value" }); Assert.False(headers.ContainsKey("host")); Assert.False(headers.ContainsKey("custom")); @@ -149,9 +149,9 @@ namespace Microsoft.AspNet.Server.KestrelTests [Fact] public void AddWorksLikeSetAndThrowsIfKeyExists() { - IDictionary headers = new FrameRequestHeaders(); + IDictionary headers = new FrameRequestHeaders(); - string[] value; + StringValues value; Assert.False(headers.TryGetValue("host", out value)); Assert.False(headers.TryGetValue("custom", out value)); @@ -169,11 +169,11 @@ namespace Microsoft.AspNet.Server.KestrelTests [Fact] public void ClearRemovesAllHeaders() { - IDictionary headers = new FrameRequestHeaders(); + IDictionary headers = new FrameRequestHeaders(); headers.Add("host", new[] { "localhost" }); headers.Add("custom", new[] { "value" }); - string[] value; + StringValues value; Assert.Equal(2, headers.Count); Assert.True(headers.TryGetValue("host", out value)); Assert.True(headers.TryGetValue("custom", out value)); @@ -188,11 +188,11 @@ namespace Microsoft.AspNet.Server.KestrelTests [Fact] public void RemoveTakesHeadersOutOfDictionary() { - IDictionary headers = new FrameRequestHeaders(); + IDictionary headers = new FrameRequestHeaders(); headers.Add("host", new[] { "localhost" }); headers.Add("custom", new[] { "value" }); - string[] value; + StringValues value; Assert.Equal(2, headers.Count); Assert.True(headers.TryGetValue("host", out value)); Assert.True(headers.TryGetValue("custom", out value)); @@ -215,24 +215,24 @@ namespace Microsoft.AspNet.Server.KestrelTests [Fact] public void CopyToMovesDataIntoArray() { - IDictionary headers = new FrameRequestHeaders(); + IDictionary headers = new FrameRequestHeaders(); headers.Add("host", new[] { "localhost" }); headers.Add("custom", new[] { "value" }); - var entries = new KeyValuePair[4]; + var entries = new KeyValuePair[4]; headers.CopyTo(entries, 1); Assert.Null(entries[0].Key); - Assert.Null(entries[0].Value); + Assert.Equal(new StringValues(), entries[0].Value); Assert.Equal("Host", entries[1].Key); - Assert.NotNull(entries[1].Value); + Assert.Equal(new[] { "localhost" }, entries[1].Value); Assert.Equal("custom", entries[2].Key); - Assert.NotNull(entries[2].Value); + Assert.Equal(new[] { "value" }, entries[2].Value); Assert.Null(entries[3].Key); - Assert.Null(entries[3].Value); + Assert.Equal(new StringValues(), entries[0].Value); } } } diff --git a/test/Microsoft.AspNet.Server.KestrelTests/FrameResponseHeadersTests.cs b/test/Microsoft.AspNet.Server.KestrelTests/FrameResponseHeadersTests.cs index 49e573c730..1e3a5570eb 100644 --- a/test/Microsoft.AspNet.Server.KestrelTests/FrameResponseHeadersTests.cs +++ b/test/Microsoft.AspNet.Server.KestrelTests/FrameResponseHeadersTests.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using Microsoft.AspNet.Server.Kestrel.Http; +using Microsoft.Framework.Primitives; using Xunit; namespace Microsoft.AspNet.Server.KestrelTests @@ -13,19 +14,19 @@ namespace Microsoft.AspNet.Server.KestrelTests [Fact] public void InitialDictionaryContainsServerAndDate() { - IDictionary headers = new FrameResponseHeaders(); + IDictionary headers = new FrameResponseHeaders(); Assert.Equal(2, headers.Count); - string[] serverHeader; + StringValues serverHeader; Assert.True(headers.TryGetValue("Server", out serverHeader)); - Assert.Equal(1, serverHeader.Length); + Assert.Equal(1, serverHeader.Count); Assert.Equal("Kestrel", serverHeader[0]); - string[] dateHeader; + StringValues dateHeader; DateTime date; Assert.True(headers.TryGetValue("Date", out dateHeader)); - Assert.Equal(1, dateHeader.Length); + Assert.Equal(1, dateHeader.Count); Assert.True(DateTime.TryParse(dateHeader[0], out date)); Assert.True(DateTime.Now - date <= TimeSpan.FromMinutes(1)); @@ -35,7 +36,7 @@ namespace Microsoft.AspNet.Server.KestrelTests [Fact] public void InitialEntriesCanBeCleared() { - IDictionary headers = new FrameResponseHeaders(); + IDictionary headers = new FrameResponseHeaders(); headers.Clear(); diff --git a/test/Microsoft.AspNet.Server.KestrelTests/MessageBodyTests.cs b/test/Microsoft.AspNet.Server.KestrelTests/MessageBodyTests.cs index 54f6e98509..c373f42d73 100644 --- a/test/Microsoft.AspNet.Server.KestrelTests/MessageBodyTests.cs +++ b/test/Microsoft.AspNet.Server.KestrelTests/MessageBodyTests.cs @@ -1,11 +1,12 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using Microsoft.AspNet.Server.Kestrel.Http; using System; using System.Collections.Generic; using System.Text; using System.Threading.Tasks; +using Microsoft.AspNet.Server.Kestrel.Http; +using Microsoft.Framework.Primitives; using Xunit; namespace Microsoft.AspNet.Server.KestrelTests @@ -19,7 +20,7 @@ namespace Microsoft.AspNet.Server.KestrelTests public void Http10ConnectionClose() { var input = new TestInput(); - var body = MessageBody.For("HTTP/1.0", new Dictionary(), input.FrameContext); + var body = MessageBody.For("HTTP/1.0", new Dictionary(), input.FrameContext); var stream = new FrameRequestStream(body); input.Add("Hello", true); @@ -38,7 +39,7 @@ namespace Microsoft.AspNet.Server.KestrelTests public async Task Http10ConnectionCloseAsync() { var input = new TestInput(); - var body = MessageBody.For("HTTP/1.0", new Dictionary(), input.FrameContext); + var body = MessageBody.For("HTTP/1.0", new Dictionary(), input.FrameContext); var stream = new FrameRequestStream(body); input.Add("Hello", true); diff --git a/tools/Microsoft.AspNet.Server.Kestrel.GeneratedCode/KnownHeaders.cs b/tools/Microsoft.AspNet.Server.Kestrel.GeneratedCode/KnownHeaders.cs index 7d02efa2ba..c9da2fd71a 100644 --- a/tools/Microsoft.AspNet.Server.Kestrel.GeneratedCode/KnownHeaders.cs +++ b/tools/Microsoft.AspNet.Server.Kestrel.GeneratedCode/KnownHeaders.cs @@ -167,6 +167,7 @@ namespace Microsoft.AspNet.Server.Kestrel.GeneratedCode return $@" using System; using System.Collections.Generic; +using Microsoft.Framework.Primitives; namespace Microsoft.AspNet.Server.Kestrel.Http {{ @@ -174,8 +175,8 @@ namespace Microsoft.AspNet.Server.Kestrel.Http {{ public FrameResponseHeaders() {{ - _Server = new[] {{ ""Kestrel"" }}; - _Date = new[] {{ DateTime.UtcNow.ToString(""r"") }}; + _Server = ""Kestrel""; + _Date = DateTime.UtcNow.ToString(""r""); _bits = { 1L << responseHeaders.First(header => header.Name == "Server").Index | 1L << responseHeaders.First(header => header.Name == "Date").Index @@ -187,7 +188,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http {{ long _bits = 0; {Each(loop.Headers, header => @" - string[] _" + header.Identifier + ";")} + StringValues _" + header.Identifier + ";")} protected override int GetCountFast() {{ @@ -201,7 +202,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http return count; }} - protected override string[] GetValueFast(string key) + protected override StringValues GetValueFast(string key) {{ switch(key.Length) {{{Each(loop.HeadersByLength, byLength => $@" @@ -228,7 +229,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http return MaybeUnknown[key]; }} - protected override bool TryGetValueFast(string key, out string[] value) + protected override bool TryGetValueFast(string key, out StringValues value) {{ switch(key.Length) {{{Each(loop.HeadersByLength, byLength => $@" @@ -243,18 +244,18 @@ namespace Microsoft.AspNet.Server.Kestrel.Http }} else {{ - value = null; + value = StringValues.Empty; return false; }} }} ")}}} break; ")}}} - value = null; + value = StringValues.Empty; return MaybeUnknown?.TryGetValue(key, out value) ?? false; }} - protected override void SetValueFast(string key, string[] value) + protected override void SetValueFast(string key, StringValues value) {{ switch(key.Length) {{{Each(loop.HeadersByLength, byLength => $@" @@ -272,7 +273,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http Unknown[key] = value; }} - protected override void AddValueFast(string key, string[] value) + protected override void AddValueFast(string key, StringValues value) {{ switch(key.Length) {{{Each(loop.HeadersByLength, byLength => $@" @@ -324,7 +325,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http MaybeUnknown?.Clear(); }} - protected override void CopyToFast(KeyValuePair[] array, int arrayIndex) + protected override void CopyToFast(KeyValuePair[] array, int arrayIndex) {{ if (arrayIndex < 0) {{ @@ -339,11 +340,11 @@ namespace Microsoft.AspNet.Server.Kestrel.Http throw new ArgumentException(); }} - array[arrayIndex] = new KeyValuePair(""{header.Name}"", _{header.Identifier}); + array[arrayIndex] = new KeyValuePair(""{header.Name}"", _{header.Identifier}); ++arrayIndex; }} ")} - ((ICollection>)MaybeUnknown)?.CopyTo(array, arrayIndex); + ((ICollection>)MaybeUnknown)?.CopyTo(array, arrayIndex); }} public unsafe void Append(byte[] keyBytes, int keyOffset, int keyLength, string value) @@ -370,8 +371,9 @@ namespace Microsoft.AspNet.Server.Kestrel.Http break; ")}}}}} var key = System.Text.Encoding.ASCII.GetString(keyBytes, keyOffset, keyLength); - string[] existing; - Unknown[key] = Unknown.TryGetValue(key, out existing) ? AppendValue(existing, value) : new[] {{value}}; + StringValues existing; + Unknown.TryGetValue(key, out existing); + Unknown[key] = AppendValue(existing, value); }} public partial struct Enumerator @@ -391,7 +393,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state{header.Index}: if ({header.TestBit()}) {{ - _current = new KeyValuePair(""{header.Name}"", _collection._{header.Identifier}); + _current = new KeyValuePair(""{header.Name}"", _collection._{header.Identifier}); _state = {header.Index + 1}; return true; }} @@ -399,7 +401,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http state_default: if (!_hasUnknown || !_unknownEnumerator.MoveNext()) {{ - _current = default(KeyValuePair); + _current = default(KeyValuePair); return false; }} _current = _unknownEnumerator.Current;