-
Notifications
You must be signed in to change notification settings - Fork 10.3k
/
Copy pathEncoderHeaderEntry.cs
69 lines (59 loc) · 1.71 KB
/
EncoderHeaderEntry.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Diagnostics;
namespace System.Net.Http.HPack;
[DebuggerDisplay("Name = {Name} Value = {Value}")]
internal sealed class EncoderHeaderEntry
{
// Header name and value
public string? Name;
public string? Value;
public uint Size;
// Chained list of headers in the same bucket
public EncoderHeaderEntry? Next;
public int Hash;
// Compute dynamic table index
public int Index;
// Doubly linked list
public EncoderHeaderEntry? Before;
public EncoderHeaderEntry? After;
/// <summary>
/// Initialize header values. An entry will be reinitialized when reused.
/// </summary>
public void Initialize(int hash, string name, string value, uint size, int index, EncoderHeaderEntry? next)
{
Debug.Assert(name != null);
Debug.Assert(value != null);
Name = name;
Value = value;
Size = size;
Index = index;
Hash = hash;
Next = next;
}
/// <summary>
/// Remove entry from the linked list and reset header values.
/// </summary>
public void Remove()
{
Before!.After = After;
After!.Before = Before;
Before = null;
After = null;
Next = null;
Hash = 0;
Name = null;
Value = null;
Size = 0;
}
/// <summary>
/// Add before an entry in the linked list.
/// </summary>
public void AddBefore(EncoderHeaderEntry existingEntry)
{
After = existingEntry;
Before = existingEntry.Before;
Before!.After = this;
After!.Before = this;
}
}