2using System.Collections.Generic;
33 private readonly Dictionary<string, string> headers =
new Dictionary<string, string>();
35 private readonly
string[] rows;
36 private readonly
string searchTarget =
string.Empty;
37 private readonly
string server =
string.Empty;
38 private readonly
string location =
string.Empty;
39 private readonly
string uniqueServiceName =
string.Empty;
40 private readonly
string verb =
string.Empty;
41 private readonly
string parameter =
string.Empty;
42 private readonly
string responseMessage =
string.Empty;
43 private readonly
string host =
string.Empty;
44 private readonly
string cacheControl =
string.Empty;
45 private readonly
string notificationType =
string.Empty;
46 private readonly
string notificationSubType =
string.Empty;
47 private readonly
double httpVersion = 0;
48 private readonly
int responseCode = 0;
55 this.rows = Header.Split(CRLF, StringSplitOptions.RemoveEmptyEntries);
60 string[] P = this.rows[0].Split(
' ');
61 if (P.Length == 3 && P[2].StartsWith(
"HTTP/"))
65 this.parameter = P[1];
67 if (!
double.TryParse(P[2].Substring(5).Replace(
".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator), out
this.httpVersion))
70 else if (P.Length >= 3 && P[0].StartsWith(
"HTTP/"))
74 if (!
double.TryParse(P[0].Substring(5).Replace(
".", System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator), out
this.httpVersion))
77 if (!
int.TryParse(P[1], out this.responseCode))
78 this.responseCode = 0;
80 this.responseMessage =
null;
81 for (i = 2; i < P.Length; i++)
83 if (this.responseMessage is
null)
84 this.responseMessage = P[i];
86 this.responseMessage +=
" " + P[i];
91 for (i = 1; i < c; i++)
96 Key = s.Substring(0, j).ToUpper();
97 Value = s.Substring(j + 1).TrimStart();
99 this.headers[Key] = Value;
104 this.searchTarget = Value;
112 this.location = Value;
116 this.uniqueServiceName = Value;
123 case "CACHE-CONTROL":
124 this.cacheControl = Value;
128 this.notificationType = Value;
132 this.notificationSubType = Value;
141 internal static readonly
char[] CRLF =
new char[] {
'\r',
'\n' };
148 public string this[
string Key]
152 if (this.headers.TryGetValue(Key, out
string Value))
167 public string Verb => this.verb;
207 public string Host => this.host;
235 return this.headers.GetEnumerator();
242 System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
244 return this.headers.GetEnumerator();
Interface for objects that contain a reference to a host.
HttpDirection
Direction of message