Skip to content

Commit fac451e

Browse files
committed
Add HPack dynamic compression
1 parent aff01eb commit fac451e

17 files changed

+1643
-559
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System.Diagnostics;
6+
using System.Net.Http.HPack;
7+
8+
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2.HPack
9+
{
10+
[DebuggerDisplay("Name = {Name} Value = {Value}")]
11+
internal class HPackHeaderEntry
12+
{
13+
// Header name and value
14+
public string Name;
15+
public string Value;
16+
17+
// Chained list of headers in the same bucket
18+
public HPackHeaderEntry Next;
19+
public int Hash;
20+
21+
// Compute dynamic table index
22+
public int Index;
23+
24+
// Doubly linked list
25+
public HPackHeaderEntry Before;
26+
public HPackHeaderEntry After;
27+
28+
/// <summary>
29+
///
30+
/// </summary>
31+
public void Initialize(int hash, string name, string value, int index, HPackHeaderEntry next)
32+
{
33+
Debug.Assert(name != null);
34+
Debug.Assert(value != null);
35+
36+
Name = name;
37+
Value = value;
38+
Index = index;
39+
Hash = hash;
40+
Next = next;
41+
}
42+
43+
public uint CalculateSize()
44+
{
45+
return (uint)HeaderField.GetLength(Name.Length, Value.Length);
46+
}
47+
48+
public void Remove()
49+
{
50+
Before.After = After;
51+
After.Before = Before;
52+
Before = null;
53+
After = null;
54+
Next = null;
55+
Hash = 0;
56+
Name = null;
57+
Value = null;
58+
}
59+
60+
public void AddBefore(HPackHeaderEntry existingEntry)
61+
{
62+
After = existingEntry;
63+
Before = existingEntry.Before;
64+
Before.After = this;
65+
After.Before = this;
66+
}
67+
}
68+
}

0 commit comments

Comments
 (0)