diff --git a/src/Servers/Kestrel/Core/src/Internal/Infrastructure/HttpUtilities.cs b/src/Servers/Kestrel/Core/src/Internal/Infrastructure/HttpUtilities.cs
index cb59fa8aff..38cd1961ff 100644
--- a/src/Servers/Kestrel/Core/src/Internal/Infrastructure/HttpUtilities.cs
+++ b/src/Servers/Kestrel/Core/src/Internal/Infrastructure/HttpUtilities.cs
@@ -430,20 +430,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure
/// A reference to the known scheme, if the input matches any
/// True when memory starts with known http or https schema
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static unsafe bool GetKnownHttpScheme(this Span span, out HttpScheme knownScheme)
+ public static bool GetKnownHttpScheme(this Span span, out HttpScheme knownScheme)
{
- fixed (byte* data = span)
+ if (BinaryPrimitives.TryReadUInt64LittleEndian(span, out var scheme))
{
- return GetKnownHttpScheme(data, span.Length, out knownScheme);
- }
- }
-
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- private static unsafe bool GetKnownHttpScheme(byte* location, int length, out HttpScheme knownScheme)
- {
- if (length >= sizeof(ulong))
- {
- var scheme = *(ulong*)location;
if ((scheme & _mask7Chars) == _httpSchemeLong)
{
knownScheme = HttpScheme.Http;