Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ReadAsync() [3/3]

override async ValueTask< int > System.Net.Http.HttpConnection.ContentLengthReadStream.ReadAsync ( Memory< byte > buffer,
CancellationToken cancellationToken )
inlinevirtual

Reimplemented from System.Net.Http.HttpBaseStream.

Definition at line 561 of file HttpConnection.cs.

562 {
563 CancellationHelper.ThrowIfCancellationRequested(cancellationToken);
564 if (_connection == null || buffer.Length == 0)
565 {
566 return 0;
567 }
568 if ((ulong)buffer.Length > _contentBytesRemaining)
569 {
570 buffer = buffer.Slice(0, (int)_contentBytesRemaining);
571 }
573 int num;
574 if (valueTask.IsCompletedSuccessfully)
575 {
576 num = valueTask.Result;
577 }
578 else
579 {
581 try
582 {
583 num = await valueTask.ConfigureAwait(continueOnCapturedContext: false);
584 }
585 catch (Exception ex) when (CancellationHelper.ShouldWrapInOperationCanceledException(ex, cancellationToken))
586 {
587 throw CancellationHelper.CreateOperationCanceledException(ex, cancellationToken);
588 }
589 finally
590 {
591 ctr.Dispose();
592 }
593 }
594 if (num <= 0)
595 {
596 CancellationHelper.ThrowIfCancellationRequested(cancellationToken);
598 }
599 _contentBytesRemaining -= (ulong)num;
601 {
603 _connection = null;
604 }
605 return num;
606 }
async ValueTask< int > ReadAsync(Memory< byte > destination)
CancellationTokenRegistration RegisterCancellation(CancellationToken cancellationToken)
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string net_http_invalid_response_premature_eof_bytecount
Definition SR.cs:98
Definition SR.cs:7

References System.Net.Http.HttpContentStream._connection, System.Net.Http.HttpConnection.ContentLengthReadStream._contentBytesRemaining, System.buffer, System.cancellationToken, System.Net.Http.HttpConnection.CompleteResponse(), System.Net.Http.CancellationHelper.CreateOperationCanceledException(), System.SR.Format(), System.L, System.SR.net_http_invalid_response_premature_eof_bytecount, System.Net.Http.HttpConnection.ReadAsync(), System.Net.Http.HttpConnection.RegisterCancellation(), System.Net.Http.CancellationHelper.ShouldWrapInOperationCanceledException(), and System.Net.Http.CancellationHelper.ThrowIfCancellationRequested().