42 base.WriteByte(
value);
75 long num2 = num - position;
119 : this(maxBufferSize, 256
L)
137 protected override void Dispose(
bool disposing)
141 base.Dispose(disposing);
172 uint num = (uint)(2 *
buffer.Length);
323 int preambleLength = -1;
518 if (tempBuffer ==
null)
550 cancellationTokenRegistration.
Dispose();
576 if (tempBuffer ==
null)
596 await serializeToStreamTask.
ConfigureAwait(continueOnCapturedContext:
false);
602 if (streamCopyException != ex)
604 throw streamCopyException;
667 if (maxBufferSize >
int.MaxValue)
684 long? contentLength = Headers.ContentLength;
685 if (contentLength.HasValue)
687 if (contentLength > maxBufferSize)
697 protected virtual void Dispose(
bool disposing)
754 return originalException;
802 return preamble.Length;
856 while (num <
prefix.Length)
871 return returnFunc(
state);
static void BlockCopy(Array src, int srcOffset, Array dst, int dstOffset, int count)
static ArrayPool< T > Shared
static void SuppressFinalize(object obj)
static CultureInfo InvariantCulture
override long Seek(long offset, SeekOrigin loc)
virtual bool TryGetBuffer(out ArraySegment< byte > buffer)
override void Dispose(bool disposing)
static void ValidateCopyToArguments(Stream destination, int bufferSize)
static byte Max(byte val1, byte val2)
static bool ShouldWrapInOperationCanceledException(Exception exception, CancellationToken cancellationToken)
static Exception CreateOperationCanceledException(Exception innerException, CancellationToken cancellationToken)
LimitArrayPoolWriteStream(int maxBufferSize)
override long Seek(long offset, SeekOrigin origin)
readonly int _maxBufferSize
void EnsureCapacity(int value)
override int Read(byte[] buffer, int offset, int count)
override void Write(ReadOnlySpan< byte > buffer)
override void SetLength(long value)
override void EndWrite(IAsyncResult asyncResult)
override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
LimitArrayPoolWriteStream(int maxBufferSize, long capacity)
override ValueTask WriteAsync(ReadOnlyMemory< byte > buffer, CancellationToken cancellationToken=default(CancellationToken))
override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState)
override Task FlushAsync(CancellationToken cancellationToken)
ArraySegment< byte > GetBuffer()
override void Write(byte[] buffer, int offset, int count)
override void Dispose(bool disposing)
override void WriteByte(byte value)
override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
LimitMemoryStream(int maxSize, int capacity)
override ValueTask WriteAsync(ReadOnlyMemory< byte > buffer, CancellationToken cancellationToken)
override void EndWrite(IAsyncResult asyncResult)
void CheckSize(int countToAdd)
override void WriteByte(byte value)
override Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken)
override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
override void Write(byte[] buffer, int offset, int count)
static Exception WrapStreamCopyException(Exception e)
virtual Task< Stream > CreateContentReadStreamAsync()
Task LoadIntoBufferAsync()
static bool TryDetectEncoding(ArraySegment< byte > buffer, [NotNullWhen(true)] out Encoding encoding, out int preambleLength)
Task< Stream > ReadAsStreamAsync()
MemoryStream _bufferedContent
void CopyTo(Stream stream, TransportContext? context, CancellationToken cancellationToken)
static Exception CreateOverCapacityException(int maxBufferSize)
static bool BufferHasPrefix(ArraySegment< byte > buffer, byte[] prefix)
Task< byte[]> ReadAsByteArrayAsync()
Task CopyToAsync(Stream stream, CancellationToken cancellationToken)
static bool StreamCopyExceptionNeedsWrapping(Exception e)
Task SerializeToStreamAsync(Stream stream, TransportContext? context)
static Exception GetStreamCopyException(Exception originalException)
virtual Stream CreateContentReadStream(CancellationToken cancellationToken)
void LoadIntoBuffer(long maxBufferSize, CancellationToken cancellationToken)
string ReadBufferedContentAsString()
bool CreateTemporaryBuffer(long maxBufferSize, out MemoryStream tempBuffer, out Exception error)
Task LoadIntoBufferAsync(CancellationToken cancellationToken)
Task< Stream > ReadAsStreamAsync(CancellationToken cancellationToken)
HttpContentHeaders _headers
Task< string > ReadAsStringAsync(CancellationToken cancellationToken)
virtual Task SerializeToStreamAsync(Stream stream, TransportContext? context, CancellationToken cancellationToken)
Task LoadIntoBufferAsync(long maxBufferSize)
Task CopyToAsync(Stream stream)
static int GetPreambleLength(ArraySegment< byte > buffer, Encoding encoding)
static readonly Encoding DefaultStringEncoding
ValueTask InternalCopyToAsync(Stream stream, TransportContext context, CancellationToken cancellationToken)
async Task LoadIntoBufferAsyncCore(Task serializeToStreamTask, MemoryStream tempBuffer)
Task LoadIntoBufferAsync(long maxBufferSize, CancellationToken cancellationToken)
virtual void Dispose(bool disposing)
bool TryComputeLength(out long length)
MemoryStream CreateMemoryStream(long maxBufferSize, out Exception error)
object _contentReadStream
Task< string > ReadAsStringAsync()
Task CopyToAsync(Stream stream, TransportContext? context)
virtual Task< Stream > CreateContentReadStreamAsync(CancellationToken cancellationToken)
long? GetComputedOrBufferLength()
void CheckTaskNotNull(Task task)
static string ReadBufferAsString(ArraySegment< byte > buffer, HttpContentHeaders headers)
Task CopyToAsync(Stream stream, TransportContext? context, CancellationToken cancellationToken)
Stream ReadAsStream(CancellationToken cancellationToken)
static async Task< TResult > WaitAndReturnAsync< TState, TResult >(Task waitTask, TState state, Func< TState, TResult > returnFunc)
byte[] ReadBufferedContentAsByteArray()
Task< byte[]> ReadAsByteArrayAsync(CancellationToken cancellationToken)
bool TryGetBuffer(out ArraySegment< byte > buffer)
virtual void SerializeToStream(Stream stream, TransportContext? context, CancellationToken cancellationToken)
virtual Stream TryCreateContentReadStream()
static readonly System.Net.NetEventSource Log
static void Info(object thisOrContextObject, FormattableString formattableString=null, [CallerMemberName] string memberName=null)
static void Error(object thisOrContextObject, FormattableString formattableString, [CallerMemberName] string memberName=null)
static string net_http_missing_sync_implementation
static string net_http_content_stream_copy_error
static string Format(string resourceFormat, object p1)
static string net_http_content_buffersize_exceeded
static string net_http_content_no_task_returned
static string net_http_content_buffersize_limit
static string net_http_content_read_as_stream_has_task
static string net_http_content_invalid_charset
static Encoding BigEndianUnicode
static Encoding GetEncoding(int codepage)
virtual byte[] GetPreamble()
unsafe string GetString(byte *bytes, int byteCount)
static IAsyncResult Begin(Task task, AsyncCallback callback, object state)
static void End(IAsyncResult asyncResult)
new ConfiguredTaskAwaitable< TResult > ConfigureAwait(bool continueOnCapturedContext)
static Task FromException(Exception exception)
static Task CompletedTask
static CancellationToken None
ConfiguredValueTaskAwaitable ConfigureAwait(bool continueOnCapturedContext)