-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRetrCommand.cs
56 lines (50 loc) · 1.71 KB
/
RetrCommand.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using System;
using System.IO;
namespace CSharpHelper
{
/// <summary>
/// This class represents the Pop3 RETR command.
/// </summary>
internal sealed class RetrCommand : Pop3Command<RetrResponse>
{
int _message;
/// <summary>
/// Initializes a new instance of the <see cref="RetrCommand"/> class.
/// </summary>
/// <param name="stream">The stream.</param>
/// <param name="message">The message.</param>
public RetrCommand(Stream stream, int message)
: base(stream, true, Pop3State.Transaction)
{
if (message < 0)
{
throw new ArgumentOutOfRangeException("message");
}
_message = message;
}
/// <summary>
/// Creates the RETR request message.
/// </summary>
/// <returns>
/// The byte[] containing the RETR request message.
/// </returns>
protected override byte[] CreateRequestMessage()
{
return GetRequestMessage(Pop3Commands.Retr, _message.ToString(), Pop3Commands.Crlf);
}
/// <summary>
/// Creates the response.
/// </summary>
/// <param name="buffer">The buffer.</param>
/// <returns>
/// The <c>Pop3Response</c> containing the results of the
/// Pop3 command execution.
/// </returns>
protected override RetrResponse CreateResponse(byte[] buffer)
{
Pop3Response response = Pop3Response.CreateResponse(buffer);
string[] messageLines = GetResponseLines(StripPop3HostMessage(buffer, response.HostMessage));
return new RetrResponse(response, messageLines);
}
}
}