bool ReadEntity() { if (AtEndBoundary) { return(false); } var entity = new MultipartHttpEntity(); // TODO: Handle split headers while (ReadNextLine() && !string.IsNullOrEmpty(_currentLine) && !AtBoundary && !AtEndBoundary) { var columnIndex = _currentLine.IndexOf(":", StringComparison.Ordinal); if (columnIndex != -1) { entity.Headers[_currentLine.Substring(0, columnIndex).Trim()] = _currentLine.Substring(columnIndex + 1).Trim(); } } if (_currentLine == null) { entity.Dispose(); return(false); } if (_currentLine.Length == 0) { entity.Stream = _reader.GetNextPart(); } CurrentEntity = entity; return(true); }
read_line_followed_by_full_read_followed_by_read_line_reads_a_line_the_rest_of_the_part_and_the_line_of_the_next_part () { GivenAMemoryStreamContaining( TextInASCII("--boundary\r\nline1\r\nline2\r\n--boundary\r\nline3\r\nline4\r\n--boundary--")); GivenABoundaryStreamReader("boundary"); Reader.SeekToNextPart(); //ensures we get to our first part Reader.ReadLine().ShouldBe("line1"); Reader.GetNextPart().ReadToEnd().ShouldBe(TextInASCII("line2")); Reader.ReadLine().ShouldBe("line3"); Reader.GetNextPart().ReadToEnd().ShouldBe(TextInASCII("line4")); }