Terraria v1.4.4.9
Terraria source code documentation
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros

◆ DrainAsync()

override async ValueTask< bool > System.Net.Http.HttpConnection.ChunkedEncodingReadStream.DrainAsync ( int maxDrainBytes)
inlinevirtual

Reimplemented from System.Net.Http.HttpConnection.HttpContentReadStream.

Definition at line 321 of file HttpConnection.cs.

322 {
325 try
326 {
327 int drainedBytes = 0;
328 while (true)
329 {
331 while (ReadChunkFromConnectionBuffer(int.MaxValue, ctr).Length != 0)
332 {
333 }
334 if (_connection == null)
335 {
336 return true;
337 }
339 {
340 return false;
341 }
342 if (cts == null)
343 {
345 if (maxResponseDrainTime == TimeSpan.Zero)
346 {
347 break;
348 }
350 {
351 cts = new CancellationTokenSource((int)maxResponseDrainTime.TotalMilliseconds);
352 ctr = cts.Token.Register(delegate(object s)
353 {
354 ((HttpConnection)s).Dispose();
355 }, _connection);
356 }
357 }
359 }
360 return false;
361 }
362 finally
363 {
364 ctr.Dispose();
365 cts?.Dispose();
366 }
367 }
ReadOnlyMemory< byte > ReadChunkFromConnectionBuffer(int maxBytesToRead, CancellationTokenRegistration cancellationRegistration)
async ValueTask FillAsync(bool async)
HttpConnection(HttpConnectionPool pool, Socket socket, Stream stream, TransportContext transportContext)
ReadOnlyMemory< byte > RemainingBuffer
readonly HttpConnectionPool _pool
static readonly TimeSpan InfiniteTimeSpan
Definition Timeout.cs:5

References System.Net.Http.HttpConnection.HttpConnection(), System.Net.Http.HttpContentStream._connection, System.Net.Http.HttpConnectionSettings._maxResponseDrainTime, System.Net.Http.HttpConnection._pool, System.Net.Http.HttpConnection.FillAsync(), System.Threading.Timeout.InfiniteTimeSpan, System.Net.Http.HttpBaseStream.Length, System.ReadOnlyMemory< T >.Length, System.Net.Http.HttpConnection.ChunkedEncodingReadStream.ReadChunkFromConnectionBuffer(), System.Net.Http.HttpConnection.RemainingBuffer, System.s, System.Net.Http.HttpConnectionPool.Settings, and System.TimeSpan.Zero.