// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Buffers; namespace Microsoft.AspNetCore.Internal { internal static class TextMessageParser { public static bool TryParseMessage(ref ReadOnlySequence buffer, out ReadOnlySequence payload) { var position = buffer.PositionOf(TextMessageFormatter.RecordSeparator); if (position == null) { payload = default; return false; } payload = buffer.Slice(0, position.Value); // Skip record separator buffer = buffer.Slice(buffer.GetPosition(1, position.Value)); return true; } } }