internal static HttpRequest Parse (string[] headerParts) { var requestLine = headerParts[0].Split (new[] { ' ' }, 3); if (requestLine.Length != 3) throw new ArgumentException ("Invalid request line: " + headerParts[0]); var headers = new WebHeaderCollection (); for (int i = 1; i < headerParts.Length; i++) headers.InternalSet (headerParts[i], false); return new HttpRequest ( requestLine[0], requestLine[1], new Version (requestLine[2].Substring (5)), headers); }
internal static HttpResponse Parse (string[] headerParts) { var statusLine = headerParts[0].Split (new[] { ' ' }, 3); if (statusLine.Length != 3) throw new ArgumentException ("Invalid status line: " + headerParts[0]); var headers = new WebHeaderCollection (); for (int i = 1; i < headerParts.Length; i++) headers.InternalSet (headerParts[i], true); return new HttpResponse ( statusLine[1], statusLine[2], new Version (statusLine[0].Substring (5)), headers); }