private string readLineFromRawRequest() { if (rawRequestPos >= RawRequest.Length) { throw new Exception("RawRequest EOF."); } var endOfLinePos = RawRequest.IndexOf('\n', rawRequestPos); if (endOfLinePos == -1) { throw new Exception("EOL not found."); } var startPos = rawRequestPos; rawRequestPos = endOfLinePos + 1; if (endOfLinePos - 1 >= 0 && RawRequest[endOfLinePos - 1] == '\r') { endOfLinePos -= 1; } return(RawRequest.Substring(startPos, endOfLinePos - startPos)); }