Method SendExtendedRequestAsync
SendExtendedRequestAsync(string, ReadOnlyMemory<byte>, CancellationToken)
Sends an SSH_FXP_EXTENDED request named name with data after the name, and returns
the server's reply as it is: for vendor extensions this client has no method for. Extensions lists what the server
announces.
public Task<SftpExtendedReply> SendExtendedRequestAsync(string name, ReadOnlyMemory<byte> data = default, CancellationToken cancellationToken = default)
Parameters
namestringThe extension's request name, for example
space-availableorvendor@example.com.dataReadOnlyMemory<byte>The request's fields after the name, at most 255 KiB; empty for none.
cancellationTokenCancellationTokenStops waiting for the reply (the server may still carry the request out).
Returns
- Task<SftpExtendedReply>
The reply's packet type and fields, and its status when it is a status.
Remarks
data is the request's fields after its name, encoded as the extension defines them (SSH strings are a big-endian
uint32 length and the bytes). The reply is usually SSH_FXP_EXTENDED_REPLY (IsExtendedReply,
with the extension's fields in Data) or SSH_FXP_STATUS (Status);
most servers answer OperationUnsupported to a request they do not know. A server error is returned,
not thrown: call EnsureSuccess() to throw it.
Some servers end the whole SFTP session on a request they do not know instead (Erlang/OTP's ssh_sftpd does), which fails
this call and every other request on the session with an SshException (ChannelClosed).
Send only extensions the server announces in Extensions.
The request goes to the server as given: an extension that changes files does so, and one that opens a handle leaves it to the
caller to close (with a raw SSH_FXP_CLOSE it cannot send through this method; such extensions are best avoided). The
server's reply is untrusted data: parse it defensively.
Exceptions
- ArgumentException
nameis empty or contains NUL.- ArgumentOutOfRangeException
datais longer than 255 KiB.