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

◆ LoadIntoBuffer()

void System.Net.Http.HttpContent.LoadIntoBuffer ( long maxBufferSize,
CancellationToken cancellationToken )
inlinepackageinherited

Definition at line 511 of file HttpContent.cs.

512 {
514 if (!CreateTemporaryBuffer(maxBufferSize, out var tempBuffer, out var error))
515 {
516 return;
517 }
518 if (tempBuffer == null)
519 {
520 throw error;
521 }
522 CancellationTokenRegistration cancellationTokenRegistration = cancellationToken.Register(delegate(object s)
523 {
524 ((HttpContent)s).Dispose();
525 }, this);
526 try
527 {
528 SerializeToStream(tempBuffer, null, cancellationToken);
529 tempBuffer.Seek(0L, SeekOrigin.Begin);
530 _bufferedContent = tempBuffer;
531 }
532 catch (Exception ex)
533 {
534 if (System.Net.NetEventSource.Log.IsEnabled())
535 {
536 System.Net.NetEventSource.Error(this, ex, "LoadIntoBuffer");
537 }
538 if (CancellationHelper.ShouldWrapInOperationCanceledException(ex, cancellationToken))
539 {
540 throw CancellationHelper.CreateOperationCanceledException(ex, cancellationToken);
541 }
543 {
544 throw GetStreamCopyException(ex);
545 }
546 throw;
547 }
548 finally
549 {
550 cancellationTokenRegistration.Dispose();
551 }
552 }
static bool StreamCopyExceptionNeedsWrapping(Exception e)
static Exception GetStreamCopyException(Exception originalException)
bool CreateTemporaryBuffer(long maxBufferSize, out MemoryStream tempBuffer, out Exception error)
virtual void SerializeToStream(Stream stream, TransportContext? context, CancellationToken cancellationToken)
static readonly System.Net.NetEventSource Log
static void Error(object thisOrContextObject, FormattableString formattableString, [CallerMemberName] string memberName=null)

References System.Net.Http.HttpContent.HttpContent(), System.Net.Http.HttpContent._bufferedContent, System.cancellationToken, System.Net.Http.HttpContent.CheckDisposed(), System.Net.Http.CancellationHelper.CreateOperationCanceledException(), System.Net.Http.HttpContent.CreateTemporaryBuffer(), System.Threading.CancellationTokenRegistration.Dispose(), System.Net.NetEventSource.Error(), System.Net.Http.HttpContent.GetStreamCopyException(), System.L, System.Net.NetEventSource.Log, System.s, System.Net.Http.HttpContent.SerializeToStream(), System.Net.Http.CancellationHelper.ShouldWrapInOperationCanceledException(), and System.Net.Http.HttpContent.StreamCopyExceptionNeedsWrapping().

Referenced by System.Net.Http.HttpContent.CreateContentReadStream(), and System.Net.Http.HttpClient.Send().