/// <summary>Constructor</summary> /// <param name="headers_section">All lines from the HTTP stream captured so far</param> /// <param name="host_name">FQDN host name, extracted from the socket stream and reverse-DNSified</param> public RequestHeaders(string headers_section, string host_name) { Hostname = host_name; headers_section.Trim(); string[] split_up = headers_section .Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); //first line is the request line if (split_up.Length < 1) { throw new Exception("Uhm, Theres supposed to be something in the headers"); } string request_line = split_up[0]; RequestLine = new HeaderRequestLine(request_line); int length = split_up.Length; HeaderLines = new List <HeaderLine>(); for (int i = 1; i < length; ++i) { HeaderLines.Add(new HeaderLine(split_up[i])); } DebugUtilities .WriteDebug($"HTTP request has {HeaderLines.Count} headers"); }
public RequestHeaders(string headers_section, string host_name) { Hostname = host_name; headers_section.Trim(); string[] split_up = headers_section.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); //first line is the request line if (split_up.Length < 1) throw new Exception("Uhm, Theres supposed to be something in the headers"); string request_line = split_up[0]; RequestLine = new HeaderRequestLine(request_line); int length = split_up.Length; HeaderLines = new List<HeaderLine>(); for (int i = 1; i < length; ++i) { HeaderLines.Add(new HeaderLine(split_up[i])); } DebugUtilities.WriteDebug("HTTP request has " + HeaderLines.Count + " headers"); }