namespace System.Net.Http.QPack
{
- // TODO: make class static.
- internal class H3StaticTable
+ internal static class H3StaticTable
{
- private readonly Dictionary<int, int> _statusIndex = new Dictionary<int, int>
+ private static readonly Dictionary<int, int> s_statusIndex = new Dictionary<int, int>
{
[103] = 24,
[200] = 25,
[500] = 71,
};
- private readonly Dictionary<HttpMethod, int> _methodIndex = new Dictionary<HttpMethod, int>
+ private static readonly Dictionary<HttpMethod, int> s_methodIndex = new Dictionary<HttpMethod, int>
{
// TODO connect is internal to system.net.http
[HttpMethod.Delete] = 16,
[HttpMethod.Put] = 21,
};
- private H3StaticTable()
- {
- }
-
- public static H3StaticTable Instance { get; } = new H3StaticTable();
-
- public int Count => _staticTable.Length;
-
- public HeaderField this[int index] => _staticTable[index];
+ public static int Count => s_staticTable.Length;
// TODO: just use Dictionary directly to avoid interface dispatch.
- public IReadOnlyDictionary<int, int> StatusIndex => _statusIndex;
- public IReadOnlyDictionary<HttpMethod, int> MethodIndex => _methodIndex;
+ public static IReadOnlyDictionary<int, int> StatusIndex => s_statusIndex;
+ public static IReadOnlyDictionary<HttpMethod, int> MethodIndex => s_methodIndex;
+
+ public static HeaderField GetHeaderFieldAt(int index) => s_staticTable[index];
- private readonly HeaderField[] _staticTable = new HeaderField[]
+ private static readonly HeaderField[] s_staticTable = new HeaderField[]
{
CreateHeaderField(":authority", ""), // 0
CreateHeaderField(":path", "/"), // 1