Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
WebHeaderCollection.cs
Go to the documentation of this file.
5using System.Text;
6
7namespace System.Net;
8
10{
12
14
16
18 {
19 get
20 {
21 if (_type == WebHeaderCollectionType.Unknown)
22 {
23 _type = WebHeaderCollectionType.WebRequest;
24 }
25 return _type == WebHeaderCollectionType.WebRequest;
26 }
27 }
28
30 {
31 get
32 {
33 if (_headerInfo == null)
34 {
36 }
37 return _headerInfo;
38 }
39 }
40
42 {
43 get
44 {
45 if (_innerCollection == null)
46 {
48 }
49 return _innerCollection;
50 }
51 }
52
54 {
55 get
56 {
57 if (_type == WebHeaderCollectionType.Unknown)
58 {
59 _type = WebHeaderCollectionType.WebResponse;
60 }
61 return _type == WebHeaderCollectionType.WebResponse;
62 }
63 }
64
65 public string? this[HttpRequestHeader header]
66 {
67 get
68 {
70 {
72 }
73 return base[header.GetName()];
74 }
75 set
76 {
78 {
80 }
81 base[header.GetName()] = value;
82 }
83 }
84
85 public string? this[HttpResponseHeader header]
86 {
87 get
88 {
90 {
92 }
93 return base[header.GetName()];
94 }
95 set
96 {
98 {
100 }
101 base[header.GetName()] = value;
102 }
103 }
104
105 public override int Count
106 {
107 get
108 {
109 if (_innerCollection != null)
110 {
111 return _innerCollection.Count;
112 }
113 return 0;
114 }
115 }
116
118
119 public override string[] AllKeys => InnerCollection.AllKeys;
120
125
126 public override void Set(string name, string? value)
127 {
128 if (string.IsNullOrEmpty(name))
129 {
130 throw new ArgumentNullException("name");
131 }
136 }
137
138 public void Set(HttpRequestHeader header, string? value)
139 {
141 {
143 }
144 Set(header.GetName(), value);
145 }
146
147 public void Set(HttpResponseHeader header, string? value)
148 {
150 {
152 }
153 Set(header.GetName(), value);
154 }
155
160
165
167 {
169 {
171 }
172 Remove(header.GetName());
173 }
174
176 {
178 {
180 }
181 Remove(header.GetName());
182 }
183
184 public override void OnDeserialization(object? sender)
185 {
186 }
187
188 public static bool IsRestricted(string headerName)
189 {
190 return IsRestricted(headerName, response: false);
191 }
192
202
203 public override string[]? GetValues(int index)
204 {
206 }
207
208 public override string[]? GetValues(string header)
209 {
212 if (headerInfo == null || values == null || !headerInfo.AllowMultiValues)
213 {
214 return values;
215 }
216 List<string> list = null;
217 for (int i = 0; i < values.Length; i++)
218 {
219 string[] array = headerInfo.Parser(values[i]);
220 if (list == null)
221 {
222 if (array != null)
223 {
224 list = new List<string>(values);
225 list.RemoveRange(i, values.Length - i);
226 list.AddRange(array);
227 }
228 }
229 else
230 {
231 list.AddRange(array);
232 }
233 }
234 if (list != null)
235 {
236 return list.ToArray();
237 }
238 return values;
239 }
240
241 public override string GetKey(int index)
242 {
244 }
245
246 public override void Clear()
247 {
249 if (_innerCollection != null)
250 {
252 }
253 }
254
255 public override string? Get(int index)
256 {
257 if (_innerCollection == null)
258 {
259 return null;
260 }
261 return _innerCollection.Get(index);
262 }
263
264 public override string? Get(string? name)
265 {
266 if (_innerCollection == null)
267 {
268 return null;
269 }
270 return _innerCollection.Get(name);
271 }
272
273 public void Add(HttpRequestHeader header, string? value)
274 {
276 {
278 }
279 Add(header.GetName(), value);
280 }
281
282 public void Add(HttpResponseHeader header, string? value)
283 {
285 {
287 }
288 Add(header.GetName(), value);
289 }
290
291 public void Add(string header)
292 {
293 if (string.IsNullOrEmpty(header))
294 {
295 throw new ArgumentNullException("header");
296 }
297 int num = header.IndexOf(':');
298 if (num < 0)
299 {
301 }
302 string name = header.Substring(0, num);
303 string value = header.Substring(num + 1);
308 }
309
310 public override void Add(string name, string? value)
311 {
312 if (name == null)
313 {
314 throw new ArgumentNullException("name");
315 }
316 if (name.Length == 0)
317 {
318 throw new ArgumentException(System.SR.Format(System.SR.net_emptyStringCall, "name"), "name");
319 }
324 }
325
333
334 public override void Remove(string name)
335 {
336 if (string.IsNullOrEmpty(name))
337 {
338 throw new ArgumentNullException("name");
339 }
341 if (_innerCollection != null)
342 {
345 }
346 }
347
348 public override string ToString()
349 {
350 if (Count == 0)
351 {
352 return "\r\n";
353 }
355 foreach (string item in InnerCollection)
356 {
357 string value = InnerCollection.Get(item);
358 stringBuilder.Append(item).Append(": ").Append(value)
359 .Append("\r\n");
360 }
361 stringBuilder.Append("\r\n");
362 return stringBuilder.ToString();
363 }
364
365 public byte[] ToByteArray()
366 {
367 string s = ToString();
368 return Encoding.ASCII.GetBytes(s);
369 }
370
372 {
373 }
374
375 public override IEnumerator GetEnumerator()
376 {
378 }
379}
virtual void Set(string? name, string? value)
static readonly CaseInsensitiveAscii StaticInstance
readonly bool IsResponseRestricted
Definition HeaderInfo.cs:7
readonly bool IsRequestRestricted
Definition HeaderInfo.cs:5
static string CheckBadHeaderNameChars(string name)
static string CheckBadHeaderValueChars(string value)
static bool IsRestricted(string headerName)
override void Remove(string name)
override? string Get(int index)
void Add(HttpRequestHeader header, string? value)
override? string Get(string? name)
void Set(HttpRequestHeader header, string? value)
void Set(HttpResponseHeader header, string? value)
override void Set(string name, string? value)
override void Add(string name, string? value)
override IEnumerator GetEnumerator()
override? string[] GetValues(int index)
override void OnDeserialization(object? sender)
WebHeaderCollection(SerializationInfo serializationInfo, StreamingContext streamingContext)
override string GetKey(int index)
static bool IsRestricted(string headerName, bool response)
void Remove(HttpRequestHeader header)
static HeaderInfoTable _headerInfo
void Add(HttpResponseHeader header, string? value)
void AddWithoutValidate(string headerName, string? headerValue)
override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext)
override? string[] GetValues(string header)
void Remove(HttpResponseHeader header)
static string net_emptyStringCall
Definition SR.cs:18
static string net_WebHeaderMissingColon
Definition SR.cs:26
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string net_headers_rsp
Definition SR.cs:16
static string net_headers_req
Definition SR.cs:14
Definition SR.cs:7
static Encoding ASCII
Definition Encoding.cs:511
void GetObjectData(SerializationInfo info, StreamingContext context)