public Append ( |
||
stream | ||
return | void |
private async Task HandleData() { await SendLine("354 OK, send"); _connection.SetTimeout(_configuration.DataCommandTimeout); using (var target = new MemoryStreamWithFileBacking(DataTransferMemoryBufferMaxSize, _configuration.TempDirectory)) { var transmissionBuffer = new TransmissionBuffer(target); while (!transmissionBuffer.TransmissionEnded) { using (var maildata = await _connection.Read()) { maildata.Seek(0, SeekOrigin.Begin); transmissionBuffer.Append(maildata); } } transmissionBuffer.Flush(); var commandResult = await _commandHandler.HandleData(target); await SendCommandResult(commandResult); _state.HasMailFrom = false; _state.HasRcptTo = false; } }
public void TransmissonBufferShouldBeEmptyAfterFlush() { var target = new MemoryStream(); var data = "Hello World\r\n.\r\n"; var bytes = Encoding.UTF8.GetBytes(data); var transmissionBuffer = new TransmissionBuffer(target); transmissionBuffer.Append(new MemoryStream(bytes)); Assert.AreEqual(0, transmissionBuffer.Size); }
public void TransmissionShouldBeMarkedAsEndedWhenDotOnNewLineIsReached() { var target = new MemoryStream(); var data = "Hello World\r\n.\r\n"; var bytes = Encoding.UTF8.GetBytes(data); var transmissionBuffer = new TransmissionBuffer(target); transmissionBuffer.Append(new MemoryStream(bytes)); Assert.IsTrue(transmissionBuffer.TransmissionEnded); }
public void TransmissionShouldBeFlushedWhenEnded() { var target = new MemoryStream(); var data = "Hello World\r\n.\r\n"; var bytes = Encoding.UTF8.GetBytes(data); var transmissionBuffer = new TransmissionBuffer(target); transmissionBuffer.Append(new MemoryStream(bytes)); target.Seek(0, SeekOrigin.Begin); var receivedData = Encoding.UTF8.GetString(target.ToArray()); Assert.AreEqual("Hello World\r\n", receivedData); }
private async Task HandleData() { await SendLine("354 OK, send"); _connection.SetTimeout(_configuration.DataCommandTimeout); using (var target = new MemoryStreamWithFileBacking(DataTransferMemoryBufferMaxSize, _configuration.TempDirectory)) { var transmissionBuffer = new TransmissionBuffer(target); while (!transmissionBuffer.TransmissionEnded) { using (var maildata = await _connection.Read()) { maildata.Seek(0, SeekOrigin.Begin); transmissionBuffer.Append(maildata); } } transmissionBuffer.Flush(); var commandResult = await _commandHandler.HandleData(target); await SendCommandResult(commandResult); _state.HasMailFrom = false; _state.HasRcptTo = false; } }