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

◆ CreateContentReadStreamAsyncCore()

async ValueTask< Stream > System.Net.Http.MultipartContent.CreateContentReadStreamAsyncCore ( bool async,
CancellationToken cancellationToken )
inlineprivateinherited

Definition at line 440 of file MultipartContent.cs.

441 {
442 _ = 1;
443 try
444 {
445 Stream[] streams = new Stream[2 + _nestedContent.Count * 2];
446 int streamIndex = 0;
449 {
450 cancellationToken.ThrowIfCancellationRequested();
454 if (async)
455 {
456 Stream stream = httpContent.TryReadAsStream();
458 if (stream2 == null)
459 {
460 stream2 = await httpContent.ReadAsStreamAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
461 }
463 }
464 else
465 {
466 stream3 = httpContent.ReadAsStream(cancellationToken);
467 }
468 if (stream3 == null)
469 {
470 stream3 = new MemoryStream();
471 }
472 if (!stream3.CanSeek)
473 {
474 return (!async) ? base.CreateContentReadStream(cancellationToken) : (await base.CreateContentReadStreamAsync().ConfigureAwait(continueOnCapturedContext: false));
475 }
477 }
478 streams[streamIndex] = EncodeStringToNewStream("\r\n--" + _boundary + "--\r\n");
479 return new ContentReadStream(streams);
480 }
481 catch (Exception message)
482 {
483 if (System.Net.NetEventSource.Log.IsEnabled())
484 {
485 System.Net.NetEventSource.Error(this, message, "CreateContentReadStreamAsyncCore");
486 }
487 throw;
488 }
489 }
Stream EncodeHeadersToNewStream(HttpContent content, bool writeDivider)
static Stream EncodeStringToNewStream(string input)
readonly List< HttpContent > _nestedContent
static readonly System.Net.NetEventSource Log
static void Error(object thisOrContextObject, FormattableString formattableString, [CallerMemberName] string memberName=null)

References System.Net.Http.MultipartContent._boundary, System.Net.Http.MultipartContent._nestedContent, System.cancellationToken, System.Collections.Generic.Dictionary< TKey, TValue >.Count, System.Net.Http.MultipartContent.EncodeHeadersToNewStream(), System.Net.Http.MultipartContent.EncodeStringToNewStream(), System.Net.NetEventSource.Error(), System.Net.NetEventSource.Log, and System.stream.

Referenced by System.Net.Http.MultipartContent.CreateContentReadStream(), System.Net.Http.MultipartContent.CreateContentReadStreamAsync(), and System.Net.Http.MultipartContent.CreateContentReadStreamAsync().