Skip to main content

ResponseStream.WriteAsync method

Sends one piece of the body, and completes when Isoplane has accepted all of it.

public ValueTask WriteAsync(ReadOnlyMemory<byte> bytes,
CancellationToken cancellationToken = default)
parameterdescription
bytesThe bytes to send. Do not change them until the returned task completes. An empty buffer sends nothing.
cancellationTokenStops the handler writing to a client that has gone away; pass Aborted. It is checked before the write begins and again when it finishes; a write in progress is not interrupted.

Exceptions​

exceptioncondition
InvalidOperationExceptionComplete has been called, or the previous write has not finished.
OperationCanceledExceptionThe token was cancelled.
IOExceptionIsoplane could not accept the piece.

Remarks​

Await each write before starting the next. Awaiting is what keeps the handler from producing output faster than it can be sent.

Once the client has gone away, a write discards its piece and completes, unless its token is cancelled.

See Also​