Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
HttpHeadersNonValidated.cs
Go to the documentation of this file.
3
5
6public readonly struct HttpHeadersNonValidated : IReadOnlyDictionary<string, HeaderStringValues>, IEnumerable<KeyValuePair<string, HeaderStringValues>>, IEnumerable, IReadOnlyCollection<KeyValuePair<string, HeaderStringValues>>
7{
8 public struct Enumerator : IEnumerator<KeyValuePair<string, HeaderStringValues>>, IEnumerator, IDisposable
9 {
11
13
14 private bool _valid;
15
17
18 object IEnumerator.Current => _current;
19
26
27 public bool MoveNext()
28 {
29 if (_valid && _headerStoreEnumerator.MoveNext())
30 {
33 _current = new KeyValuePair<string, HeaderStringValues>(current.Key.Name, (singleValue != null) ? new HeaderStringValues(current.Key, singleValue) : new HeaderStringValues(current.Key, multiValue));
34 return true;
35 }
37 return false;
38 }
39
40 public void Dispose()
41 {
42 }
43
45 {
46 throw new NotSupportedException();
47 }
48 }
49
50 private readonly HttpHeaders _headers;
51
52 public int Count => (_headers?.HeaderStore?.Count).GetValueOrDefault();
53
54 public HeaderStringValues this[string headerName]
55 {
56 get
57 {
59 {
60 return values;
61 }
63 }
64 }
65
67 {
68 get
69 {
71 while (enumerator.MoveNext())
72 {
73 yield return enumerator.Current.Key;
74 }
75 }
76 }
77
79 {
80 get
81 {
83 while (enumerator.MoveNext())
84 {
85 yield return enumerator.Current.Value;
86 }
87 }
88 }
89
94
95 public bool Contains(string headerName)
96 {
98 object value;
99 if (headers != null && HeaderDescriptor.TryGet(headerName, out var descriptor))
100 {
101 return headers.TryGetHeaderValue(descriptor, out value);
102 }
103 return false;
104 }
105
110
112 {
114 if (headers != null && HeaderDescriptor.TryGet(headerName, out var descriptor) && headers.TryGetHeaderValue(descriptor, out var value))
115 {
117 values = ((singleValue != null) ? new HeaderStringValues(descriptor, singleValue) : new HeaderStringValues(descriptor, multiValue));
118 return true;
119 }
120 values = default(HeaderStringValues);
121 return false;
122 }
123
128
130 {
132 if (headers != null)
133 {
135 if (headerStore != null)
136 {
138 }
139 }
140 return default(Enumerator);
141 }
142
147
152}
bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value)
Dictionary< HeaderDescriptor, object >? HeaderStore
static void GetStoreValuesAsStringOrStringArray(HeaderDescriptor descriptor, object sourceValues, out string singleValue, out string[] multiValue)
static string net_http_headers_not_found
Definition SR.cs:20
Definition SR.cs:7
new IEnumerator< T > GetEnumerator()
static bool TryGet(string headerName, out HeaderDescriptor descriptor)
Dictionary< HeaderDescriptor, object >.Enumerator _headerStoreEnumerator
Enumerator(Dictionary< HeaderDescriptor, object >.Enumerator headerStoreEnumerator)
bool TryGetValues(string headerName, out HeaderStringValues values)