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

◆ CopyToContentLengthAsync()

async Task System.Net.Http.HttpConnection.CopyToContentLengthAsync ( Stream destination,
bool async,
ulong length,
int bufferSize,
CancellationToken cancellationToken )
inlineprivate

Definition at line 2479 of file HttpConnection.cs.

2480 {
2482 if (remaining > 0)
2483 {
2484 if ((ulong)remaining > length)
2485 {
2486 remaining = (int)length;
2487 }
2489 length -= (ulong)remaining;
2490 if (length == 0L)
2491 {
2492 return;
2493 }
2494 }
2495 byte[] origReadBuffer = null;
2496 try
2497 {
2498 while (true)
2499 {
2501 remaining = (((ulong)_readLength < length) ? _readLength : ((int)length));
2503 length -= (ulong)remaining;
2504 if (length == 0L)
2505 {
2506 break;
2507 }
2508 if (origReadBuffer != null)
2509 {
2510 continue;
2511 }
2512 byte[] readBuffer = _readBuffer;
2513 if (remaining == readBuffer.Length)
2514 {
2515 int num = (int)Math.Min((ulong)bufferSize, length);
2516 if (num > readBuffer.Length)
2517 {
2518 origReadBuffer = readBuffer;
2519 _readBuffer = ArrayPool<byte>.Shared.Rent(num);
2520 }
2521 }
2522 }
2523 }
2524 finally
2525 {
2526 if (origReadBuffer != null)
2527 {
2528 byte[] readBuffer2 = _readBuffer;
2530 ArrayPool<byte>.Shared.Return(readBuffer2);
2531 _readLength = ((_readOffset < _readLength) ? 1 : 0);
2532 _readOffset = 0;
2533 }
2534 }
2535 }
async ValueTask FillAsync(bool async)
ValueTask CopyFromBufferAsync(Stream destination, bool async, int count, CancellationToken cancellationToken)
ConfiguredValueTaskAwaitable ConfigureAwait(bool continueOnCapturedContext)
Definition ValueTask.cs:312

References System.Net.Http.HttpConnection._readBuffer, System.Net.Http.HttpConnection._readLength, System.Net.Http.HttpConnection._readOffset, System.cancellationToken, System.Threading.Tasks.ValueTask< TResult >.ConfigureAwait(), System.Net.Http.HttpConnection.CopyFromBufferAsync(), System.destination, System.Net.Http.HttpConnection.FillAsync(), System.L, System.length, and System.Math.Min().

Referenced by System.Net.Http.HttpConnection.ContentLengthReadStream.CopyToAsync().