React to corefxlab changes (#1539)
- Removed use of TryRead and follow the pin and use pattern in the other APIs https://github.com/dotnet/corefxlab/pull/1348
This commit is contained in:
parent
ff99c4c865
commit
f090b7a9c6
|
|
@ -36,7 +36,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
|
||||
// Prepare the first span
|
||||
var span = buffer.First.Span;
|
||||
var lineIndex = span.SequentialIndexOf(ByteLF);
|
||||
var lineIndex = span.IndexOf(ByteLF);
|
||||
if (lineIndex >= 0)
|
||||
{
|
||||
consumed = buffer.Move(consumed, lineIndex + 1);
|
||||
|
|
@ -255,7 +255,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
index = reader.Index;
|
||||
}
|
||||
|
||||
var endIndex = new Span<byte>(pBuffer + index, remaining).SequentialIndexOf(ByteLF);
|
||||
var endIndex = new Span<byte>(pBuffer + index, remaining).IndexOf(ByteLF);
|
||||
var length = 0;
|
||||
|
||||
if (endIndex != -1)
|
||||
|
|
|
|||
|
|
@ -270,23 +270,32 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure
|
|||
/// <param name="knownScheme">A reference to the known scheme, if the input matches any</param>
|
||||
/// <returns>True when memory starts with known http or https schema</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool GetKnownHttpScheme(this Span<byte> span, out HttpScheme knownScheme)
|
||||
public static unsafe bool GetKnownHttpScheme(this Span<byte> span, out HttpScheme knownScheme)
|
||||
{
|
||||
if (span.TryRead<ulong>(out var value))
|
||||
fixed (byte* data = &span.DangerousGetPinnableReference())
|
||||
{
|
||||
if ((value & _mask7Chars) == _httpSchemeLong)
|
||||
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;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (value == _httpsSchemeLong)
|
||||
if (scheme == _httpsSchemeLong)
|
||||
{
|
||||
knownScheme = HttpScheme.Https;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
knownScheme = HttpScheme.Unknown;
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue