Files
Rob Hague bafd867c12 Rent buffers used in SFTP reads (#1738)
An SFTP download performs several reads from the server in parallel, allocating an array
to store each result until it's ready to be consumed. Since these buffers are short-lived
and normally of the same large-ish size (32KB), it seems like a good candidate for pooling.
2025-11-21 19:54:25 +01:00

41 lines
964 B
C#

using System;
using Renci.SshNet.Sftp.Responses;
namespace Renci.SshNet.Tests.Classes.Sftp
{
internal class SftpDataResponseBuilder
{
private uint _protocolVersion;
private uint _responseId;
private byte[] _data;
public SftpDataResponseBuilder WithProtocolVersion(uint protocolVersion)
{
_protocolVersion = protocolVersion;
return this;
}
public SftpDataResponseBuilder WithResponseId(uint responseId)
{
_responseId = responseId;
return this;
}
public SftpDataResponseBuilder WithData(byte[] data)
{
_data = data;
return this;
}
public SftpDataResponse Build()
{
return new SftpDataResponse(_protocolVersion)
{
ResponseId = _responseId,
Data = new ArraySegment<byte>(_data)
};
}
}
}