mirror of
https://github.com/sshnet/SSH.NET.git
synced 2026-09-11 13:39:09 +00:00
bafd867c12
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.
41 lines
964 B
C#
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)
|
|
};
|
|
}
|
|
}
|
|
}
|