|
2 | 2 | using System;
|
3 | 3 | using System.Collections.Generic;
|
4 | 4 | using System.Text;
|
| 5 | +using Microsoft.AspNet.Server.Kestrel.Infrastructure; |
5 | 6 | using Microsoft.Extensions.Primitives;
|
6 | 7 |
|
7 | 8 | namespace Microsoft.AspNet.Server.Kestrel.Http
|
8 | 9 | {
|
9 | 10 |
|
10 | 11 | public partial class FrameRequestHeaders
|
11 | 12 | {
|
12 |
| - |
13 | 13 | private long _bits = 0;
|
14 | 14 |
|
15 | 15 | private StringValues _CacheControl;
|
@@ -592,7 +592,8 @@ public StringValues HeaderUserAgent
|
592 | 592 |
|
593 | 593 | protected override int GetCountFast()
|
594 | 594 | {
|
595 |
| - return BitCount(_bits) + (MaybeUnknown?.Count ?? 0); |
| 595 | + return BitCount(_bits) |
| 596 | + + (MaybeUnknown?.Count ?? 0); |
596 | 597 | }
|
597 | 598 |
|
598 | 599 | protected override StringValues GetValueFast(string key)
|
@@ -5038,7 +5039,6 @@ public partial class FrameResponseHeaders
|
5038 | 5039 | private static byte[] _bytesSetCookie = Encoding.ASCII.GetBytes("Set-Cookie: ");
|
5039 | 5040 | private static byte[] _bytesVary = Encoding.ASCII.GetBytes("Vary: ");
|
5040 | 5041 | private static byte[] _bytesWWWAuthenticate = Encoding.ASCII.GetBytes("WWW-Authenticate: ");
|
5041 |
| - |
5042 | 5042 | private long _bits = 0;
|
5043 | 5043 |
|
5044 | 5044 | private StringValues _CacheControl;
|
@@ -5071,6 +5071,26 @@ public partial class FrameResponseHeaders
|
5071 | 5071 | private StringValues _SetCookie;
|
5072 | 5072 | private StringValues _Vary;
|
5073 | 5073 | private StringValues _WWWAuthenticate;
|
| 5074 | + private bool _hasDefaultServer; |
| 5075 | + private bool _hasDefaultDate; |
| 5076 | + |
| 5077 | + public bool HasDefaultServer { |
| 5078 | + get { return _hasDefaultServer; } |
| 5079 | + set |
| 5080 | + { |
| 5081 | + _hasDefaultServer = value; |
| 5082 | + _bits &= ~67108864L; |
| 5083 | + } |
| 5084 | + } |
| 5085 | + |
| 5086 | + public bool HasDefaultDate { |
| 5087 | + get { return _hasDefaultDate; } |
| 5088 | + set |
| 5089 | + { |
| 5090 | + _hasDefaultDate = value; |
| 5091 | + _bits &= ~4L; |
| 5092 | + } |
| 5093 | + } |
5074 | 5094 |
|
5075 | 5095 | public StringValues HeaderCacheControl
|
5076 | 5096 | {
|
@@ -5108,6 +5128,7 @@ public StringValues HeaderDate
|
5108 | 5128 | set
|
5109 | 5129 | {
|
5110 | 5130 | _bits |= 4L;
|
| 5131 | + HasDefaultDate = false; |
5111 | 5132 | _Date = value;
|
5112 | 5133 | }
|
5113 | 5134 | }
|
@@ -5422,6 +5443,7 @@ public StringValues HeaderServer
|
5422 | 5443 | set
|
5423 | 5444 | {
|
5424 | 5445 | _bits |= 67108864L;
|
| 5446 | + HasDefaultServer = false; |
5425 | 5447 | _Server = value;
|
5426 | 5448 | }
|
5427 | 5449 | }
|
@@ -5467,7 +5489,9 @@ public StringValues HeaderWWWAuthenticate
|
5467 | 5489 |
|
5468 | 5490 | protected override int GetCountFast()
|
5469 | 5491 | {
|
5470 |
| - return BitCount(_bits) + (MaybeUnknown?.Count ?? 0); |
| 5492 | + return BitCount(_bits) + (HasDefaultDate ? 1 : 0) |
| 5493 | + + (HasDefaultServer ? 1 : 0) |
| 5494 | + + (MaybeUnknown?.Count ?? 0); |
5471 | 5495 | }
|
5472 | 5496 |
|
5473 | 5497 | protected override StringValues GetValueFast(string key)
|
@@ -6007,6 +6031,11 @@ protected override bool TryGetValueFast(string key, out StringValues value)
|
6007 | 6031 | {
|
6008 | 6032 | if ("Date".Equals(key, StringComparison.OrdinalIgnoreCase))
|
6009 | 6033 | {
|
| 6034 | + if (HasDefaultDate) |
| 6035 | + { |
| 6036 | + value = DateTime.UtcNow.ToString(Constants.RFC1123DateFormat); |
| 6037 | + return true; |
| 6038 | + } |
6010 | 6039 | if (((_bits & 4L) != 0))
|
6011 | 6040 | {
|
6012 | 6041 | value = _Date;
|
@@ -6067,6 +6096,11 @@ protected override bool TryGetValueFast(string key, out StringValues value)
|
6067 | 6096 |
|
6068 | 6097 | if ("Server".Equals(key, StringComparison.OrdinalIgnoreCase))
|
6069 | 6098 | {
|
| 6099 | + if (HasDefaultServer) |
| 6100 | + { |
| 6101 | + value = "Kestrel"; |
| 6102 | + return true; |
| 6103 | + } |
6070 | 6104 | if (((_bits & 67108864L) != 0))
|
6071 | 6105 | {
|
6072 | 6106 | value = _Server;
|
@@ -6441,6 +6475,7 @@ protected override void SetValueFast(string key, StringValues value)
|
6441 | 6475 | {
|
6442 | 6476 | _bits |= 4L;
|
6443 | 6477 | _Date = value;
|
| 6478 | + HasDefaultDate = false; |
6444 | 6479 | return;
|
6445 | 6480 | }
|
6446 | 6481 |
|
@@ -6473,6 +6508,7 @@ protected override void SetValueFast(string key, StringValues value)
|
6473 | 6508 | {
|
6474 | 6509 | _bits |= 67108864L;
|
6475 | 6510 | _Server = value;
|
| 6511 | + HasDefaultServer = false; |
6476 | 6512 | return;
|
6477 | 6513 | }
|
6478 | 6514 | }
|
@@ -6745,6 +6781,7 @@ protected override void AddValueFast(string key, StringValues value)
|
6745 | 6781 | }
|
6746 | 6782 | _bits |= 4L;
|
6747 | 6783 | _Date = value;
|
| 6784 | + HasDefaultDate = false; |
6748 | 6785 | return;
|
6749 | 6786 | }
|
6750 | 6787 |
|
@@ -6793,6 +6830,7 @@ protected override void AddValueFast(string key, StringValues value)
|
6793 | 6830 | }
|
6794 | 6831 | _bits |= 67108864L;
|
6795 | 6832 | _Server = value;
|
| 6833 | + HasDefaultServer = false; |
6796 | 6834 | return;
|
6797 | 6835 | }
|
6798 | 6836 | }
|
@@ -7156,6 +7194,7 @@ protected override bool RemoveFast(string key)
|
7156 | 7194 | {
|
7157 | 7195 | _bits &= ~4L;
|
7158 | 7196 | _Date = StringValues.Empty;
|
| 7197 | + HasDefaultDate = false; |
7159 | 7198 | return true;
|
7160 | 7199 | }
|
7161 | 7200 | else
|
@@ -7216,6 +7255,7 @@ protected override bool RemoveFast(string key)
|
7216 | 7255 | {
|
7217 | 7256 | _bits &= ~67108864L;
|
7218 | 7257 | _Server = StringValues.Empty;
|
| 7258 | + HasDefaultServer = false; |
7219 | 7259 | return true;
|
7220 | 7260 | }
|
7221 | 7261 | else
|
@@ -7557,6 +7597,8 @@ protected override void ClearFast()
|
7557 | 7597 | HasConnection = false;
|
7558 | 7598 | HasTransferEncoding = false;
|
7559 | 7599 | HasContentLength = false;
|
| 7600 | + HasDefaultServer = false; |
| 7601 | + HasDefaultDate = false; |
7560 | 7602 | }
|
7561 | 7603 |
|
7562 | 7604 | protected override void CopyToFast(KeyValuePair<string, StringValues>[] array, int arrayIndex)
|
@@ -8023,6 +8065,7 @@ public unsafe void Append(byte[] keyBytes, int keyOffset, int keyLength, string
|
8023 | 8065 | else
|
8024 | 8066 | {
|
8025 | 8067 | _bits |= 4L;
|
| 8068 | + HasDefaultDate = false; |
8026 | 8069 | _Date = new StringValues(value);
|
8027 | 8070 | }
|
8028 | 8071 | return;
|
@@ -8083,6 +8126,7 @@ public unsafe void Append(byte[] keyBytes, int keyOffset, int keyLength, string
|
8083 | 8126 | else
|
8084 | 8127 | {
|
8085 | 8128 | _bits |= 67108864L;
|
| 8129 | + HasDefaultServer = false; |
8086 | 8130 | _Server = new StringValues(value);
|
8087 | 8131 | }
|
8088 | 8132 | return;
|
@@ -8504,6 +8548,12 @@ public bool MoveNext()
|
8504 | 8548 | }
|
8505 | 8549 |
|
8506 | 8550 | state2:
|
| 8551 | + if (_collection.HasDefaultDate) |
| 8552 | + { |
| 8553 | + _current = new KeyValuePair<string, StringValues>("Date", DateTime.UtcNow.ToString(Constants.RFC1123DateFormat)); |
| 8554 | + _state = 3; |
| 8555 | + return true; |
| 8556 | + } |
8507 | 8557 | if (((_bits & 4L) != 0))
|
8508 | 8558 | {
|
8509 | 8559 | _current = new KeyValuePair<string, StringValues>("Date", _collection._Date);
|
@@ -8696,6 +8746,12 @@ public bool MoveNext()
|
8696 | 8746 | }
|
8697 | 8747 |
|
8698 | 8748 | state26:
|
| 8749 | + if (_collection.HasDefaultServer) |
| 8750 | + { |
| 8751 | + _current = new KeyValuePair<string, StringValues>("Server", "Kestrel"); |
| 8752 | + _state = 27; |
| 8753 | + return true; |
| 8754 | + } |
8699 | 8755 | if (((_bits & 67108864L) != 0))
|
8700 | 8756 | {
|
8701 | 8757 | _current = new KeyValuePair<string, StringValues>("Server", _collection._Server);
|
|
0 commit comments