private void ParseHeaders(string[] requestLines) { int emptyLineAfterHeadersIndex = Array.IndexOf(requestLines, string.Empty); for (int i = 1; i < emptyLineAfterHeadersIndex; i++) { var currentLine = requestLines[i]; string[] headerParts = currentLine .Split(new[] { ": " }, StringSplitOptions.None); if (headerParts.Length != 2) { throw new BadRequestException(); } string key = headerParts[0]; string value = headerParts[1].Trim(); this.Headers.Add(new HttpHeader(key, value)); } if (!Headers.ContrainsKey("Host")) { throw new BadRequestException(); } }