public async Task <ResponseLine> ReadLine(bool validate = true) { var ms = new MemoryStream(); while (true) { if (_pos == _length) { await FillBuffer(); } for (; _pos < _length; ++_pos) { if (_buffer[_pos] == '\r') { continue; } if (_buffer[_pos] == '\n') { ++_pos; ms.Position = 0; var line = _encoding.GetString(ms.ToArray()); var result = new ResponseLine(line); if (validate) { result.Validate(); } return(result); } ms.WriteByte(_buffer[_pos]); } } }
public async Task<ResponseLine> ReadLine(bool validate = true) { var ms = new MemoryStream(); while (true) { if (_pos == _length) await FillBuffer(); for (; _pos < _length; ++_pos) { if (_buffer[_pos] == '\r') continue; if (_buffer[_pos] == '\n') { ++_pos; ms.Position = 0; var line = _encoding.GetString(ms.ToArray()); var result = new ResponseLine(line); if (validate) result.Validate(); return result; } ms.WriteByte(_buffer[_pos]); } } }