/// <summary>
/// Checks 9 bytes from <paramref name="begin"/> correspond to a known HTTP version.
/// </summary>
/// <remarks>
/// A "known HTTP version" Is is either HTTP/1.0 or HTTP/1.1.
/// Since those fit in 8 bytes, they can be optimally looked up by reading those bytes as a long. Once
/// in that format, it can be checked against the known versions.
/// The Known versions will be checked with the required '\r'.
/// To optimize performance the HTTP/1.1 will be checked first.
/// </remarks>
/// <param name="begin">The iterator from which to start the known string lookup.</param>
/// <param name="scan">If we found a valid method, then scan will be updated to new position</param>
/// <param name="knownMethod">A reference to a pre-allocated known string, if the input matches any.</param>
/// <returns><c>true</c> if the input matches a known string, <c>false</c> otherwise.</returns>
public static bool GetKnownVersion(this MemoryPoolIterator2 begin, ref MemoryPoolIterator2 scan, out string knownVersion)
{
knownVersion = null;
var value = begin.PeekLong();
if (value == _http11VersionLong)
{
knownVersion = Http11Version;
scan.Skip(8);
if (scan.Take() == '\r')
{
return(true);
}
}
else if (value == _http10VersionLong)
{
knownVersion = Http10Version;
scan.Skip(8);
if (scan.Take() == '\r')
{
return(true);
}
}
knownVersion = null;
return(false);
}