internal ValueTask <(HeaderEnumerator Headers, bool IsHeader, Memory <char> PushBack)> ReadAsync(CancellationToken cancellationToken) { var madeProgress = true; while (true) { var availableTask = Buffer.ReadAsync(InnerAsync.Value, madeProgress, cancellationToken); if (!availableTask.IsCompletedSuccessfully(this)) { return(ReadAsync_ContinueAfterReadAsync(this, availableTask, cancellationToken)); } var available = availableTask.Result; if (available == 0) { if (BuilderBacking.Length > 0) { var inEscapedValue = ReaderStateMachine.IsInEscapedValue(StateMachine.CurrentState); PushPendingCharactersToValue(inEscapedValue); } break; } else { AddToPushback(Buffer.Buffer.Span.Slice(0, available)); } if (AdvanceWork(available, out madeProgress)) { break; } } return(new ValueTask <(HeaderEnumerator Headers, bool IsHeader, Memory <char> PushBack)>(IsHeaderResult()));
internal ValueTask <(HeaderEnumerator Headers, bool IsHeader, Memory <char> PushBack)> ReadAsync(CancellationToken cancel) { while (true) { var availableTask = Buffer.ReadAsync(Inner, cancel); if (!availableTask.IsCompletedSuccessfully) { return(ReadAsync_ContinueAfterReadAsync(this, availableTask, cancel)); } var available = availableTask.Result; if (available == 0) { if (BuilderBacking.Length > 0) { PushPendingCharactersToValue(); } break; } else { AddToPushback(Buffer.Buffer.Span.Slice(0, available)); } if (AdvanceWork(available)) { break; } } return(new ValueTask <(HeaderEnumerator Headers, bool IsHeader, Memory <char> PushBack)>(IsHeaderResult()));