Revert "Use Spans to parse the start line and headers (#1394)"
This reverts commit 8140b8cdfe.
This commit is contained in:
parent
4544f881a2
commit
19c3107deb
|
|
@ -1,6 +1,6 @@
|
|||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.26206.0
|
||||
VisualStudioVersion = 15.0.26213.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{7972A5D6-3385-4127-9277-428506DD44FF}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<Import Project="..\..\build\common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netcoreapp1.1;net451</TargetFrameworks>
|
||||
<TargetFrameworks>net451;netcoreapp1.1</TargetFrameworks>
|
||||
<OutputType>Exe</OutputType>
|
||||
<!-- TODO remove rid when https://github.com/dotnet/sdk/issues/396 is resolved -->
|
||||
<RuntimeIdentifier Condition="'$(TargetFramework)'!='netcoreapp1.1'">win7-x64</RuntimeIdentifier>
|
||||
|
|
|
|||
|
|
@ -997,16 +997,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
|
||||
_requestProcessingStatus = RequestProcessingStatus.RequestStarted;
|
||||
|
||||
ReadableBuffer limitedBuffer;
|
||||
var limitedBuffer = buffer;
|
||||
if (buffer.Length >= ServerOptions.Limits.MaxRequestLineSize)
|
||||
{
|
||||
limitedBuffer = buffer.Slice(0, ServerOptions.Limits.MaxRequestLineSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
limitedBuffer = buffer;
|
||||
}
|
||||
|
||||
if (ReadCursorOperations.Seek(limitedBuffer.Start, limitedBuffer.End, out end, ByteLF) == -1)
|
||||
{
|
||||
if (limitedBuffer.Length == ServerOptions.Limits.MaxRequestLineSize)
|
||||
|
|
@ -1019,46 +1014,17 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
}
|
||||
}
|
||||
|
||||
const int stackAllocLimit = 512;
|
||||
|
||||
// Move 1 byte past the \r
|
||||
end = limitedBuffer.Move(end, 1);
|
||||
var startLineBuffer = limitedBuffer.Slice(0, end);
|
||||
|
||||
Span<byte> span;
|
||||
|
||||
if (startLineBuffer.IsSingleSpan)
|
||||
end = buffer.Move(end, 1);
|
||||
ReadCursor methodEnd;
|
||||
string method;
|
||||
if (!buffer.GetKnownMethod(out method))
|
||||
{
|
||||
// No copies, directly use the one and only span
|
||||
span = startLineBuffer.ToSpan();
|
||||
}
|
||||
else if (startLineBuffer.Length < stackAllocLimit)
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
// Multiple buffers and < stackAllocLimit, copy into a stack buffer
|
||||
byte* stackBuffer = stackalloc byte[startLineBuffer.Length];
|
||||
span = new Span<byte>(stackBuffer, startLineBuffer.Length);
|
||||
startLineBuffer.CopyTo(span);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// We're not a single span here but we can use pooled arrays to avoid allocations in the rare case
|
||||
span = new Span<byte>(new byte[startLineBuffer.Length]);
|
||||
startLineBuffer.CopyTo(span);
|
||||
}
|
||||
|
||||
var methodEnd = 0;
|
||||
if (!span.GetKnownMethod(out string method))
|
||||
{
|
||||
methodEnd = span.IndexOf(ByteSpace);
|
||||
if (methodEnd == -1)
|
||||
if (ReadCursorOperations.Seek(buffer.Start, end, out methodEnd, ByteSpace) == -1)
|
||||
{
|
||||
RejectRequestLine(start, end);
|
||||
}
|
||||
|
||||
method = span.Slice(0, methodEnd).GetAsciiString();
|
||||
method = buffer.Slice(buffer.Start, methodEnd).GetAsciiString();
|
||||
|
||||
if (method == null)
|
||||
{
|
||||
|
|
@ -1077,67 +1043,57 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
}
|
||||
else
|
||||
{
|
||||
methodEnd += method.Length;
|
||||
methodEnd = buffer.Slice(method.Length).Start;
|
||||
}
|
||||
|
||||
var needDecode = false;
|
||||
var pathBegin = methodEnd + 1;
|
||||
var pathToEndSpan = span.Slice(pathBegin, span.Length - pathBegin);
|
||||
pathBegin = 0;
|
||||
ReadCursor pathEnd;
|
||||
|
||||
// TODO: IndexOfAny
|
||||
var spaceIndex = pathToEndSpan.IndexOf(ByteSpace);
|
||||
var questionMarkIndex = pathToEndSpan.IndexOf(ByteQuestionMark);
|
||||
var percentageIndex = pathToEndSpan.IndexOf(BytePercentage);
|
||||
var pathBegin = buffer.Move(methodEnd, 1);
|
||||
|
||||
var pathEnd = MinNonZero(spaceIndex, questionMarkIndex, percentageIndex);
|
||||
|
||||
if (spaceIndex == -1 && questionMarkIndex == -1 && percentageIndex == -1)
|
||||
var chFound = ReadCursorOperations.Seek(pathBegin, end, out pathEnd, ByteSpace, ByteQuestionMark, BytePercentage);
|
||||
if (chFound == -1)
|
||||
{
|
||||
RejectRequestLine(start, end);
|
||||
}
|
||||
else if (percentageIndex != -1)
|
||||
else if (chFound == BytePercentage)
|
||||
{
|
||||
needDecode = true;
|
||||
|
||||
pathEnd = MinNonZero(spaceIndex, questionMarkIndex);
|
||||
if (questionMarkIndex == -1 && spaceIndex == -1)
|
||||
chFound = ReadCursorOperations.Seek(pathBegin, end, out pathEnd, ByteSpace, ByteQuestionMark);
|
||||
if (chFound == -1)
|
||||
{
|
||||
RejectRequestLine(start, end);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var queryString = "";
|
||||
var queryEnd = pathEnd;
|
||||
if (questionMarkIndex != -1)
|
||||
ReadCursor queryEnd = pathEnd;
|
||||
if (chFound == ByteQuestionMark)
|
||||
{
|
||||
queryEnd = spaceIndex;
|
||||
if (spaceIndex == -1)
|
||||
if (ReadCursorOperations.Seek(pathEnd, end, out queryEnd, ByteSpace) == -1)
|
||||
{
|
||||
RejectRequestLine(start, end);
|
||||
}
|
||||
|
||||
queryString = pathToEndSpan.Slice(pathEnd, queryEnd - pathEnd).GetAsciiString();
|
||||
queryString = buffer.Slice(pathEnd, queryEnd).GetAsciiString();
|
||||
}
|
||||
|
||||
// No path
|
||||
if (pathBegin == pathEnd)
|
||||
{
|
||||
RejectRequestLine(start, end);
|
||||
}
|
||||
|
||||
var versionBegin = queryEnd + 1;
|
||||
var versionToEndSpan = pathToEndSpan.Slice(versionBegin, pathToEndSpan.Length - versionBegin);
|
||||
versionBegin = 0;
|
||||
var versionEnd = versionToEndSpan.IndexOf(ByteCR);
|
||||
|
||||
if (versionEnd == -1)
|
||||
ReadCursor versionEnd;
|
||||
if (ReadCursorOperations.Seek(queryEnd, end, out versionEnd, ByteCR) == -1)
|
||||
{
|
||||
RejectRequestLine(start, end);
|
||||
}
|
||||
|
||||
if (!versionToEndSpan.GetKnownVersion(out string httpVersion))
|
||||
string httpVersion;
|
||||
var versionBuffer = buffer.Slice(queryEnd, end).Slice(1);
|
||||
if (!versionBuffer.GetKnownVersion(out httpVersion))
|
||||
{
|
||||
httpVersion = versionToEndSpan.Slice(0, versionEnd).GetAsciiStringEscaped();
|
||||
httpVersion = versionBuffer.Start.GetAsciiStringEscaped(versionEnd, 9);
|
||||
|
||||
if (httpVersion == string.Empty)
|
||||
{
|
||||
|
|
@ -1149,13 +1105,14 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
}
|
||||
}
|
||||
|
||||
if (versionToEndSpan[versionEnd + 1] != ByteLF)
|
||||
var lineEnd = buffer.Slice(versionEnd, 2).ToSpan();
|
||||
if (lineEnd[1] != ByteLF)
|
||||
{
|
||||
RejectRequestLine(start, end);
|
||||
}
|
||||
|
||||
var pathBuffer = pathToEndSpan.Slice(pathBegin, pathEnd);
|
||||
var targetBuffer = pathToEndSpan.Slice(pathBegin, queryEnd);
|
||||
var pathBuffer = buffer.Slice(pathBegin, pathEnd);
|
||||
var targetBuffer = buffer.Slice(pathBegin, queryEnd);
|
||||
|
||||
// URIs are always encoded/escaped to ASCII https://tools.ietf.org/html/rfc3986#page-11
|
||||
// Multibyte Internationalized Resource Identifiers (IRIs) are first converted to utf8;
|
||||
|
|
@ -1168,7 +1125,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
rawTarget = targetBuffer.GetAsciiString() ?? string.Empty;
|
||||
|
||||
// URI was encoded, unescape and then parse as utf8
|
||||
var pathSpan = pathBuffer;
|
||||
var pathSpan = pathBuffer.ToSpan();
|
||||
int pathLength = UrlEncoder.Decode(pathSpan, pathSpan);
|
||||
requestUrlPath = new Utf8String(pathSpan.Slice(0, pathLength)).ToString();
|
||||
}
|
||||
|
|
@ -1218,21 +1175,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
return true;
|
||||
}
|
||||
|
||||
private int MinNonZero(int v1, int v2)
|
||||
{
|
||||
v1 = v1 == -1 ? int.MaxValue : v1;
|
||||
v2 = v2 == -1 ? int.MaxValue : v2;
|
||||
return Math.Min(v1, v2);
|
||||
}
|
||||
|
||||
private int MinNonZero(int v1, int v2, int v3)
|
||||
{
|
||||
v1 = v1 == -1 ? int.MaxValue : v1;
|
||||
v2 = v2 == -1 ? int.MaxValue : v2;
|
||||
v3 = v3 == -1 ? int.MaxValue : v3;
|
||||
return Math.Min(Math.Min(v1, v2), v3);
|
||||
}
|
||||
|
||||
private void RejectRequestLine(ReadCursor start, ReadCursor end)
|
||||
{
|
||||
const int MaxRequestLineError = 32;
|
||||
|
|
@ -1302,41 +1244,40 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
consumed = buffer.Start;
|
||||
examined = buffer.End;
|
||||
|
||||
var bufferLength = buffer.Length;
|
||||
var reader = new ReadableBufferReader(buffer);
|
||||
|
||||
while (true)
|
||||
{
|
||||
var start = reader;
|
||||
int ch1 = reader.Take();
|
||||
var ch2 = reader.Take();
|
||||
var headersEnd = buffer.Slice(0, Math.Min(buffer.Length, 2));
|
||||
var headersEndSpan = headersEnd.ToSpan();
|
||||
|
||||
if (ch1 == -1)
|
||||
if (headersEndSpan.Length == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ch1 == ByteCR)
|
||||
else
|
||||
{
|
||||
// Check for final CRLF.
|
||||
if (ch2 == -1)
|
||||
var ch = headersEndSpan[0];
|
||||
if (ch == ByteCR)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (ch2 == ByteLF)
|
||||
{
|
||||
consumed = reader.Cursor;
|
||||
examined = consumed;
|
||||
ConnectionControl.CancelTimeout();
|
||||
return true;
|
||||
}
|
||||
// Check for final CRLF.
|
||||
if (headersEndSpan.Length < 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (headersEndSpan[1] == ByteLF)
|
||||
{
|
||||
consumed = headersEnd.End;
|
||||
examined = consumed;
|
||||
ConnectionControl.CancelTimeout();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Headers don't end in CRLF line.
|
||||
RejectRequest(RequestRejectionReason.HeadersCorruptedInvalidHeaderSequence);
|
||||
}
|
||||
else if (ch1 == ByteSpace || ch1 == ByteTab)
|
||||
{
|
||||
RejectRequest(RequestRejectionReason.HeaderLineMustNotStartWithWhitespace);
|
||||
// Headers don't end in CRLF line.
|
||||
RejectRequest(RequestRejectionReason.HeadersCorruptedInvalidHeaderSequence);
|
||||
}
|
||||
else if (ch == ByteSpace || ch == ByteTab)
|
||||
{
|
||||
RejectRequest(RequestRejectionReason.HeaderLineMustNotStartWithWhitespace);
|
||||
}
|
||||
}
|
||||
|
||||
// If we've parsed the max allowed numbers of headers and we're starting a new
|
||||
|
|
@ -1346,30 +1287,15 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
RejectRequest(RequestRejectionReason.TooManyHeaders);
|
||||
}
|
||||
|
||||
// Reset the reader since we're not at the end of headers
|
||||
reader = start;
|
||||
|
||||
// Now parse a single header
|
||||
ReadableBuffer limitedBuffer;
|
||||
var overLength = false;
|
||||
|
||||
if (bufferLength >= _remainingRequestHeadersBytesAllowed)
|
||||
ReadCursor lineEnd;
|
||||
var limitedBuffer = buffer;
|
||||
if (buffer.Length >= _remainingRequestHeadersBytesAllowed)
|
||||
{
|
||||
limitedBuffer = buffer.Slice(consumed, _remainingRequestHeadersBytesAllowed);
|
||||
|
||||
// If we sliced it means the current buffer bigger than what we're
|
||||
// allowed to look at
|
||||
overLength = true;
|
||||
limitedBuffer = buffer.Slice(0, _remainingRequestHeadersBytesAllowed);
|
||||
}
|
||||
else
|
||||
if (ReadCursorOperations.Seek(limitedBuffer.Start, limitedBuffer.End, out lineEnd, ByteLF) == -1)
|
||||
{
|
||||
limitedBuffer = buffer;
|
||||
}
|
||||
|
||||
if (ReadCursorOperations.Seek(consumed, limitedBuffer.End, out var lineEnd, ByteLF) == -1)
|
||||
{
|
||||
// We didn't find a \n in the current buffer and we had to slice it so it's an issue
|
||||
if (overLength)
|
||||
if (limitedBuffer.Length == _remainingRequestHeadersBytesAllowed)
|
||||
{
|
||||
RejectRequest(RequestRejectionReason.HeadersExceedMaxTotalSize);
|
||||
}
|
||||
|
|
@ -1379,94 +1305,39 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
}
|
||||
}
|
||||
|
||||
const int stackAllocLimit = 512;
|
||||
|
||||
if (lineEnd != limitedBuffer.End)
|
||||
{
|
||||
lineEnd = limitedBuffer.Move(lineEnd, 1);
|
||||
}
|
||||
|
||||
var headerBuffer = limitedBuffer.Slice(consumed, lineEnd);
|
||||
|
||||
Span<byte> span;
|
||||
if (headerBuffer.IsSingleSpan)
|
||||
{
|
||||
// No copies, directly use the one and only span
|
||||
span = headerBuffer.ToSpan();
|
||||
}
|
||||
else if (headerBuffer.Length < stackAllocLimit)
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
// Multiple buffers and < stackAllocLimit, copy into a stack buffer
|
||||
byte* stackBuffer = stackalloc byte[headerBuffer.Length];
|
||||
span = new Span<byte>(stackBuffer, headerBuffer.Length);
|
||||
headerBuffer.CopyTo(span);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// We're not a single span here but we can use pooled arrays to avoid allocations in the rare case
|
||||
span = new Span<byte>(new byte[headerBuffer.Length]);
|
||||
headerBuffer.CopyTo(span);
|
||||
}
|
||||
|
||||
int endNameIndex = span.IndexOf(ByteColon);
|
||||
if (endNameIndex == -1)
|
||||
var beginName = buffer.Start;
|
||||
ReadCursor endName;
|
||||
if (ReadCursorOperations.Seek(buffer.Start, lineEnd, out endName, ByteColon) == -1)
|
||||
{
|
||||
RejectRequest(RequestRejectionReason.NoColonCharacterFoundInHeaderLine);
|
||||
}
|
||||
|
||||
var nameBuffer = span.Slice(0, endNameIndex);
|
||||
if (nameBuffer.IndexOf(ByteSpace) != -1 || nameBuffer.IndexOf(ByteTab) != -1)
|
||||
ReadCursor whitespace;
|
||||
if (ReadCursorOperations.Seek(beginName, endName, out whitespace, ByteTab, ByteSpace) != -1)
|
||||
{
|
||||
RejectRequest(RequestRejectionReason.WhitespaceIsNotAllowedInHeaderName);
|
||||
}
|
||||
|
||||
int endValueIndex = span.IndexOf(ByteCR);
|
||||
if (endValueIndex == -1)
|
||||
ReadCursor endValue;
|
||||
if (ReadCursorOperations.Seek(beginName, lineEnd, out endValue, ByteCR) == -1)
|
||||
{
|
||||
RejectRequest(RequestRejectionReason.MissingCRInHeaderLine);
|
||||
}
|
||||
|
||||
var lineSuffix = span.Slice(endValueIndex);
|
||||
if (lineSuffix.Length < 2)
|
||||
var lineSufix = buffer.Slice(endValue);
|
||||
if (lineSufix.Length < 3)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
lineSufix = lineSufix.Slice(0, 3); // \r\n\r
|
||||
var lineSufixSpan = lineSufix.ToSpan();
|
||||
// This check and MissingCRInHeaderLine is a bit backwards, we should do it at once instead of having another seek
|
||||
if (lineSuffix[1] != ByteLF)
|
||||
if (lineSufixSpan[1] != ByteLF)
|
||||
{
|
||||
RejectRequest(RequestRejectionReason.HeaderValueMustNotContainCR);
|
||||
}
|
||||
|
||||
// Trim trailing whitespace from header value by repeatedly advancing to next
|
||||
// whitespace or CR.
|
||||
//
|
||||
// - If CR is found, this is the end of the header value.
|
||||
// - If whitespace is found, this is the _tentative_ end of the header value.
|
||||
// If non-whitespace is found after it and it's not CR, seek again to the next
|
||||
// whitespace or CR for a new (possibly tentative) end of value.
|
||||
|
||||
var valueBuffer = span.Slice(endNameIndex + 1, endValueIndex - (endNameIndex + 1));
|
||||
|
||||
// TODO: Trim else where
|
||||
var value = valueBuffer.GetAsciiString()?.Trim() ?? string.Empty;
|
||||
|
||||
var headerLineLength = span.Length;
|
||||
|
||||
// -1 so that we can re-check the extra \r
|
||||
reader.Skip(headerLineLength);
|
||||
|
||||
var next = reader.Peek();
|
||||
|
||||
// We cant check for line continuations to reject everything we've done so far
|
||||
if (next == -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var next = lineSufixSpan[2];
|
||||
if (next == ByteSpace || next == ByteTab)
|
||||
{
|
||||
// From https://tools.ietf.org/html/rfc7230#section-3.2.4:
|
||||
|
|
@ -1489,15 +1360,31 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
RejectRequest(RequestRejectionReason.HeaderValueLineFoldingNotSupported);
|
||||
}
|
||||
|
||||
// Update the frame state only after we know there's no header line continuation
|
||||
_remainingRequestHeadersBytesAllowed -= headerLineLength;
|
||||
bufferLength -= headerLineLength;
|
||||
// Trim trailing whitespace from header value by repeatedly advancing to next
|
||||
// whitespace or CR.
|
||||
//
|
||||
// - If CR is found, this is the end of the header value.
|
||||
// - If whitespace is found, this is the _tentative_ end of the header value.
|
||||
// If non-whitespace is found after it and it's not CR, seek again to the next
|
||||
// whitespace or CR for a new (possibly tentative) end of value.
|
||||
|
||||
var nameBuffer = buffer.Slice(beginName, endName);
|
||||
|
||||
// TODO: TrimStart and TrimEnd are pretty slow
|
||||
var valueBuffer = buffer.Slice(endName, endValue).Slice(1).TrimStart().TrimEnd();
|
||||
|
||||
var name = nameBuffer.ToArraySegment();
|
||||
var value = valueBuffer.GetAsciiString();
|
||||
|
||||
lineEnd = limitedBuffer.Move(lineEnd, 1);
|
||||
|
||||
// TODO: bad
|
||||
_remainingRequestHeadersBytesAllowed -= buffer.Slice(0, lineEnd).Length;
|
||||
_requestHeadersParsed++;
|
||||
|
||||
requestHeaders.Append(nameBuffer, value);
|
||||
|
||||
consumed = reader.Cursor;
|
||||
requestHeaders.Append(name.Array, name.Offset, name.Count, value);
|
||||
buffer = buffer.Slice(lineEnd);
|
||||
consumed = buffer.Start;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3501,10 +3501,12 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
}
|
||||
|
||||
|
||||
public unsafe void Append(byte* pKeyBytes, int keyLength, string value)
|
||||
public unsafe void Append(byte[] keyBytes, int keyOffset, int keyLength, string value)
|
||||
{
|
||||
var pUB = pKeyBytes;
|
||||
var pUL = (ulong*)pUB;
|
||||
fixed (byte* ptr = &keyBytes[keyOffset])
|
||||
{
|
||||
var pUB = ptr;
|
||||
var pUL = (ulong*)pUB;
|
||||
var pUI = (uint*)pUB;
|
||||
var pUS = (ushort*)pUB;
|
||||
var stringValue = new StringValues(value);
|
||||
|
|
@ -3565,10 +3567,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
break;
|
||||
}
|
||||
|
||||
AppendNonPrimaryHeaders(pKeyBytes, keyLength, value);
|
||||
AppendNonPrimaryHeaders(ptr, keyOffset, keyLength, value);
|
||||
}
|
||||
}
|
||||
|
||||
private unsafe void AppendNonPrimaryHeaders(byte* pKeyBytes, int keyLength, string value)
|
||||
|
||||
private unsafe void AppendNonPrimaryHeaders(byte* pKeyBytes, int keyOffset, int keyLength, string value)
|
||||
{
|
||||
var pUB = pKeyBytes;
|
||||
var pUL = (ulong*)pUB;
|
||||
|
|
@ -7764,10 +7767,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
}
|
||||
else
|
||||
{
|
||||
var valueCount = _headers._Connection.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
var valueCount = _headers._Connection.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
{
|
||||
var value = _headers._Connection[i];
|
||||
var value = _headers._Connection[i];
|
||||
if (value != null)
|
||||
{
|
||||
output.CopyFrom(_headerBytes, 17, 14);
|
||||
|
|
@ -7790,10 +7793,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
}
|
||||
else
|
||||
{
|
||||
var valueCount = _headers._Date.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
var valueCount = _headers._Date.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
{
|
||||
var value = _headers._Date[i];
|
||||
var value = _headers._Date[i];
|
||||
if (value != null)
|
||||
{
|
||||
output.CopyFrom(_headerBytes, 31, 8);
|
||||
|
|
@ -7811,10 +7814,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
if ((tempBits & 2048L) != 0)
|
||||
{
|
||||
{
|
||||
var valueCount = _headers._ContentType.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
var valueCount = _headers._ContentType.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
{
|
||||
var value = _headers._ContentType[i];
|
||||
var value = _headers._ContentType[i];
|
||||
if (value != null)
|
||||
{
|
||||
output.CopyFrom(_headerBytes, 133, 16);
|
||||
|
|
@ -7837,10 +7840,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
}
|
||||
else
|
||||
{
|
||||
var valueCount = _headers._Server.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
var valueCount = _headers._Server.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
{
|
||||
var value = _headers._Server[i];
|
||||
var value = _headers._Server[i];
|
||||
if (value != null)
|
||||
{
|
||||
output.CopyFrom(_headerBytes, 350, 10);
|
||||
|
|
@ -7869,10 +7872,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
if ((tempBits & 1L) != 0)
|
||||
{
|
||||
{
|
||||
var valueCount = _headers._CacheControl.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
var valueCount = _headers._CacheControl.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
{
|
||||
var value = _headers._CacheControl[i];
|
||||
var value = _headers._CacheControl[i];
|
||||
if (value != null)
|
||||
{
|
||||
output.CopyFrom(_headerBytes, 0, 17);
|
||||
|
|
@ -7890,10 +7893,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
if ((tempBits & 8L) != 0)
|
||||
{
|
||||
{
|
||||
var valueCount = _headers._KeepAlive.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
var valueCount = _headers._KeepAlive.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
{
|
||||
var value = _headers._KeepAlive[i];
|
||||
var value = _headers._KeepAlive[i];
|
||||
if (value != null)
|
||||
{
|
||||
output.CopyFrom(_headerBytes, 39, 14);
|
||||
|
|
@ -7911,10 +7914,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
if ((tempBits & 16L) != 0)
|
||||
{
|
||||
{
|
||||
var valueCount = _headers._Pragma.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
var valueCount = _headers._Pragma.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
{
|
||||
var value = _headers._Pragma[i];
|
||||
var value = _headers._Pragma[i];
|
||||
if (value != null)
|
||||
{
|
||||
output.CopyFrom(_headerBytes, 53, 10);
|
||||
|
|
@ -7932,10 +7935,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
if ((tempBits & 32L) != 0)
|
||||
{
|
||||
{
|
||||
var valueCount = _headers._Trailer.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
var valueCount = _headers._Trailer.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
{
|
||||
var value = _headers._Trailer[i];
|
||||
var value = _headers._Trailer[i];
|
||||
if (value != null)
|
||||
{
|
||||
output.CopyFrom(_headerBytes, 63, 11);
|
||||
|
|
@ -7958,10 +7961,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
}
|
||||
else
|
||||
{
|
||||
var valueCount = _headers._TransferEncoding.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
var valueCount = _headers._TransferEncoding.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
{
|
||||
var value = _headers._TransferEncoding[i];
|
||||
var value = _headers._TransferEncoding[i];
|
||||
if (value != null)
|
||||
{
|
||||
output.CopyFrom(_headerBytes, 74, 21);
|
||||
|
|
@ -7979,10 +7982,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
if ((tempBits & 128L) != 0)
|
||||
{
|
||||
{
|
||||
var valueCount = _headers._Upgrade.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
var valueCount = _headers._Upgrade.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
{
|
||||
var value = _headers._Upgrade[i];
|
||||
var value = _headers._Upgrade[i];
|
||||
if (value != null)
|
||||
{
|
||||
output.CopyFrom(_headerBytes, 95, 11);
|
||||
|
|
@ -8000,10 +8003,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
if ((tempBits & 256L) != 0)
|
||||
{
|
||||
{
|
||||
var valueCount = _headers._Via.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
var valueCount = _headers._Via.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
{
|
||||
var value = _headers._Via[i];
|
||||
var value = _headers._Via[i];
|
||||
if (value != null)
|
||||
{
|
||||
output.CopyFrom(_headerBytes, 106, 7);
|
||||
|
|
@ -8021,10 +8024,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
if ((tempBits & 512L) != 0)
|
||||
{
|
||||
{
|
||||
var valueCount = _headers._Warning.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
var valueCount = _headers._Warning.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
{
|
||||
var value = _headers._Warning[i];
|
||||
var value = _headers._Warning[i];
|
||||
if (value != null)
|
||||
{
|
||||
output.CopyFrom(_headerBytes, 113, 11);
|
||||
|
|
@ -8042,10 +8045,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
if ((tempBits & 1024L) != 0)
|
||||
{
|
||||
{
|
||||
var valueCount = _headers._Allow.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
var valueCount = _headers._Allow.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
{
|
||||
var value = _headers._Allow[i];
|
||||
var value = _headers._Allow[i];
|
||||
if (value != null)
|
||||
{
|
||||
output.CopyFrom(_headerBytes, 124, 9);
|
||||
|
|
@ -8063,10 +8066,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
if ((tempBits & 4096L) != 0)
|
||||
{
|
||||
{
|
||||
var valueCount = _headers._ContentEncoding.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
var valueCount = _headers._ContentEncoding.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
{
|
||||
var value = _headers._ContentEncoding[i];
|
||||
var value = _headers._ContentEncoding[i];
|
||||
if (value != null)
|
||||
{
|
||||
output.CopyFrom(_headerBytes, 149, 20);
|
||||
|
|
@ -8084,10 +8087,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
if ((tempBits & 8192L) != 0)
|
||||
{
|
||||
{
|
||||
var valueCount = _headers._ContentLanguage.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
var valueCount = _headers._ContentLanguage.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
{
|
||||
var value = _headers._ContentLanguage[i];
|
||||
var value = _headers._ContentLanguage[i];
|
||||
if (value != null)
|
||||
{
|
||||
output.CopyFrom(_headerBytes, 169, 20);
|
||||
|
|
@ -8105,10 +8108,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
if ((tempBits & 16384L) != 0)
|
||||
{
|
||||
{
|
||||
var valueCount = _headers._ContentLocation.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
var valueCount = _headers._ContentLocation.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
{
|
||||
var value = _headers._ContentLocation[i];
|
||||
var value = _headers._ContentLocation[i];
|
||||
if (value != null)
|
||||
{
|
||||
output.CopyFrom(_headerBytes, 189, 20);
|
||||
|
|
@ -8126,10 +8129,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
if ((tempBits & 32768L) != 0)
|
||||
{
|
||||
{
|
||||
var valueCount = _headers._ContentMD5.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
var valueCount = _headers._ContentMD5.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
{
|
||||
var value = _headers._ContentMD5[i];
|
||||
var value = _headers._ContentMD5[i];
|
||||
if (value != null)
|
||||
{
|
||||
output.CopyFrom(_headerBytes, 209, 15);
|
||||
|
|
@ -8147,10 +8150,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
if ((tempBits & 65536L) != 0)
|
||||
{
|
||||
{
|
||||
var valueCount = _headers._ContentRange.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
var valueCount = _headers._ContentRange.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
{
|
||||
var value = _headers._ContentRange[i];
|
||||
var value = _headers._ContentRange[i];
|
||||
if (value != null)
|
||||
{
|
||||
output.CopyFrom(_headerBytes, 224, 17);
|
||||
|
|
@ -8168,10 +8171,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
if ((tempBits & 131072L) != 0)
|
||||
{
|
||||
{
|
||||
var valueCount = _headers._Expires.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
var valueCount = _headers._Expires.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
{
|
||||
var value = _headers._Expires[i];
|
||||
var value = _headers._Expires[i];
|
||||
if (value != null)
|
||||
{
|
||||
output.CopyFrom(_headerBytes, 241, 11);
|
||||
|
|
@ -8189,10 +8192,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
if ((tempBits & 262144L) != 0)
|
||||
{
|
||||
{
|
||||
var valueCount = _headers._LastModified.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
var valueCount = _headers._LastModified.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
{
|
||||
var value = _headers._LastModified[i];
|
||||
var value = _headers._LastModified[i];
|
||||
if (value != null)
|
||||
{
|
||||
output.CopyFrom(_headerBytes, 252, 17);
|
||||
|
|
@ -8210,10 +8213,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
if ((tempBits & 524288L) != 0)
|
||||
{
|
||||
{
|
||||
var valueCount = _headers._AcceptRanges.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
var valueCount = _headers._AcceptRanges.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
{
|
||||
var value = _headers._AcceptRanges[i];
|
||||
var value = _headers._AcceptRanges[i];
|
||||
if (value != null)
|
||||
{
|
||||
output.CopyFrom(_headerBytes, 269, 17);
|
||||
|
|
@ -8231,10 +8234,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
if ((tempBits & 1048576L) != 0)
|
||||
{
|
||||
{
|
||||
var valueCount = _headers._Age.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
var valueCount = _headers._Age.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
{
|
||||
var value = _headers._Age[i];
|
||||
var value = _headers._Age[i];
|
||||
if (value != null)
|
||||
{
|
||||
output.CopyFrom(_headerBytes, 286, 7);
|
||||
|
|
@ -8252,10 +8255,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
if ((tempBits & 2097152L) != 0)
|
||||
{
|
||||
{
|
||||
var valueCount = _headers._ETag.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
var valueCount = _headers._ETag.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
{
|
||||
var value = _headers._ETag[i];
|
||||
var value = _headers._ETag[i];
|
||||
if (value != null)
|
||||
{
|
||||
output.CopyFrom(_headerBytes, 293, 8);
|
||||
|
|
@ -8273,10 +8276,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
if ((tempBits & 4194304L) != 0)
|
||||
{
|
||||
{
|
||||
var valueCount = _headers._Location.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
var valueCount = _headers._Location.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
{
|
||||
var value = _headers._Location[i];
|
||||
var value = _headers._Location[i];
|
||||
if (value != null)
|
||||
{
|
||||
output.CopyFrom(_headerBytes, 301, 12);
|
||||
|
|
@ -8294,10 +8297,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
if ((tempBits & 8388608L) != 0)
|
||||
{
|
||||
{
|
||||
var valueCount = _headers._ProxyAuthenticate.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
var valueCount = _headers._ProxyAuthenticate.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
{
|
||||
var value = _headers._ProxyAuthenticate[i];
|
||||
var value = _headers._ProxyAuthenticate[i];
|
||||
if (value != null)
|
||||
{
|
||||
output.CopyFrom(_headerBytes, 313, 22);
|
||||
|
|
@ -8315,10 +8318,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
if ((tempBits & 16777216L) != 0)
|
||||
{
|
||||
{
|
||||
var valueCount = _headers._RetryAfter.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
var valueCount = _headers._RetryAfter.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
{
|
||||
var value = _headers._RetryAfter[i];
|
||||
var value = _headers._RetryAfter[i];
|
||||
if (value != null)
|
||||
{
|
||||
output.CopyFrom(_headerBytes, 335, 15);
|
||||
|
|
@ -8336,10 +8339,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
if ((tempBits & 67108864L) != 0)
|
||||
{
|
||||
{
|
||||
var valueCount = _headers._SetCookie.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
var valueCount = _headers._SetCookie.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
{
|
||||
var value = _headers._SetCookie[i];
|
||||
var value = _headers._SetCookie[i];
|
||||
if (value != null)
|
||||
{
|
||||
output.CopyFrom(_headerBytes, 360, 14);
|
||||
|
|
@ -8357,10 +8360,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
if ((tempBits & 134217728L) != 0)
|
||||
{
|
||||
{
|
||||
var valueCount = _headers._Vary.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
var valueCount = _headers._Vary.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
{
|
||||
var value = _headers._Vary[i];
|
||||
var value = _headers._Vary[i];
|
||||
if (value != null)
|
||||
{
|
||||
output.CopyFrom(_headerBytes, 374, 8);
|
||||
|
|
@ -8378,10 +8381,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
if ((tempBits & 268435456L) != 0)
|
||||
{
|
||||
{
|
||||
var valueCount = _headers._WWWAuthenticate.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
var valueCount = _headers._WWWAuthenticate.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
{
|
||||
var value = _headers._WWWAuthenticate[i];
|
||||
var value = _headers._WWWAuthenticate[i];
|
||||
if (value != null)
|
||||
{
|
||||
output.CopyFrom(_headerBytes, 382, 20);
|
||||
|
|
@ -8399,10 +8402,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
if ((tempBits & 536870912L) != 0)
|
||||
{
|
||||
{
|
||||
var valueCount = _headers._AccessControlAllowCredentials.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
var valueCount = _headers._AccessControlAllowCredentials.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
{
|
||||
var value = _headers._AccessControlAllowCredentials[i];
|
||||
var value = _headers._AccessControlAllowCredentials[i];
|
||||
if (value != null)
|
||||
{
|
||||
output.CopyFrom(_headerBytes, 402, 36);
|
||||
|
|
@ -8420,10 +8423,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
if ((tempBits & 1073741824L) != 0)
|
||||
{
|
||||
{
|
||||
var valueCount = _headers._AccessControlAllowHeaders.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
var valueCount = _headers._AccessControlAllowHeaders.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
{
|
||||
var value = _headers._AccessControlAllowHeaders[i];
|
||||
var value = _headers._AccessControlAllowHeaders[i];
|
||||
if (value != null)
|
||||
{
|
||||
output.CopyFrom(_headerBytes, 438, 32);
|
||||
|
|
@ -8441,10 +8444,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
if ((tempBits & 2147483648L) != 0)
|
||||
{
|
||||
{
|
||||
var valueCount = _headers._AccessControlAllowMethods.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
var valueCount = _headers._AccessControlAllowMethods.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
{
|
||||
var value = _headers._AccessControlAllowMethods[i];
|
||||
var value = _headers._AccessControlAllowMethods[i];
|
||||
if (value != null)
|
||||
{
|
||||
output.CopyFrom(_headerBytes, 470, 32);
|
||||
|
|
@ -8462,10 +8465,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
if ((tempBits & 4294967296L) != 0)
|
||||
{
|
||||
{
|
||||
var valueCount = _headers._AccessControlAllowOrigin.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
var valueCount = _headers._AccessControlAllowOrigin.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
{
|
||||
var value = _headers._AccessControlAllowOrigin[i];
|
||||
var value = _headers._AccessControlAllowOrigin[i];
|
||||
if (value != null)
|
||||
{
|
||||
output.CopyFrom(_headerBytes, 502, 31);
|
||||
|
|
@ -8483,10 +8486,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
if ((tempBits & 8589934592L) != 0)
|
||||
{
|
||||
{
|
||||
var valueCount = _headers._AccessControlExposeHeaders.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
var valueCount = _headers._AccessControlExposeHeaders.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
{
|
||||
var value = _headers._AccessControlExposeHeaders[i];
|
||||
var value = _headers._AccessControlExposeHeaders[i];
|
||||
if (value != null)
|
||||
{
|
||||
output.CopyFrom(_headerBytes, 533, 33);
|
||||
|
|
@ -8504,10 +8507,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
if ((tempBits & 17179869184L) != 0)
|
||||
{
|
||||
{
|
||||
var valueCount = _headers._AccessControlMaxAge.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
var valueCount = _headers._AccessControlMaxAge.Count;
|
||||
for (var i = 0; i < valueCount; i++)
|
||||
{
|
||||
var value = _headers._AccessControlMaxAge[i];
|
||||
var value = _headers._AccessControlMaxAge[i];
|
||||
if (value != null)
|
||||
{
|
||||
output.CopyFrom(_headerBytes, 566, 26);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
// 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.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
|
@ -30,14 +29,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
Unknown[key] = value;
|
||||
}
|
||||
|
||||
public unsafe void Append(Span<byte> name, string value)
|
||||
{
|
||||
fixed (byte* namePtr = &name.DangerousGetPinnableReference())
|
||||
{
|
||||
Append(namePtr, name.Length, value);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||||
private unsafe void AppendUnknownHeaders(byte* pKeyBytes, int keyLength, string value)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -90,19 +90,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure
|
|||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static string GetAsciiStringEscaped(this Span<byte> span)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
|
||||
for (var i = 0; i < span.Length; ++i)
|
||||
{
|
||||
var ch = span[i];
|
||||
sb.Append(ch < 0x20 || ch >= 0x7F ? $"<0x{ch:X2}>" : ((char)ch).ToString());
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static ArraySegment<byte> PeekArraySegment(this MemoryPoolIterator iter)
|
||||
{
|
||||
if (iter.IsDefault || iter.IsEnd)
|
||||
|
|
@ -170,33 +157,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure
|
|||
return false;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool GetKnownMethod(this Span<byte> span, out string knownMethod)
|
||||
{
|
||||
knownMethod = null;
|
||||
if (span.Length < sizeof(ulong))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ulong value = span.Read<ulong>();
|
||||
if ((value & _mask4Chars) == _httpGetMethodLong)
|
||||
{
|
||||
knownMethod = HttpMethods.Get;
|
||||
return true;
|
||||
}
|
||||
foreach (var x in _knownMethods)
|
||||
{
|
||||
if ((value & x.Item1) == x.Item2)
|
||||
{
|
||||
knownMethod = x.Item3;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks 9 bytes from <paramref name="begin"/> correspond to a known HTTP version.
|
||||
/// </summary>
|
||||
|
|
@ -240,36 +200,5 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure
|
|||
|
||||
return knownVersion != null;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool GetKnownVersion(this Span<byte> span, out string knownVersion)
|
||||
{
|
||||
knownVersion = null;
|
||||
|
||||
if (span.Length < sizeof(ulong))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var value = span.Read<ulong>();
|
||||
if (value == _http11VersionLong)
|
||||
{
|
||||
knownVersion = Http11Version;
|
||||
}
|
||||
else if (value == _http10VersionLong)
|
||||
{
|
||||
knownVersion = Http10Version;
|
||||
}
|
||||
|
||||
if (knownVersion != null)
|
||||
{
|
||||
if (span[sizeof(ulong)] != (byte)'\r')
|
||||
{
|
||||
knownVersion = null;
|
||||
}
|
||||
}
|
||||
|
||||
return knownVersion != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,4 +30,4 @@
|
|||
<PackageReference Include="System.Threading.ThreadPool" Version="$(CoreFxVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -311,7 +311,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
|
|||
|
||||
var encoding = Encoding.GetEncoding("iso-8859-1");
|
||||
var exception = Assert.Throws<BadHttpRequestException>(
|
||||
() => headers.Append(encoding.GetBytes(key), key));
|
||||
() => headers.Append(encoding.GetBytes(key), 0, encoding.GetByteCount(key), key));
|
||||
Assert.Equal(StatusCodes.Status400BadRequest, exception.StatusCode);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -611,7 +611,7 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
|
|||
var exception = Assert.Throws<BadHttpRequestException>(() => _frame.TakeStartLine(readableBuffer, out consumed, out examined));
|
||||
_socketInput.Reader.Advance(consumed, examined);
|
||||
|
||||
Assert.Equal("Unrecognized HTTP version: HTTP/1.1ab", exception.Message);
|
||||
Assert.Equal("Unrecognized HTTP version: HTTP/1.1a...", exception.Message);
|
||||
Assert.Equal(StatusCodes.Status505HttpVersionNotsupported, exception.StatusCode);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -564,15 +564,18 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Http
|
|||
}}" : "")}")}
|
||||
}}" : "")}
|
||||
{(loop.ClassName == "FrameRequestHeaders" ? $@"
|
||||
public unsafe void Append(byte* pKeyBytes, int keyLength, string value)
|
||||
public unsafe void Append(byte[] keyBytes, int keyOffset, int keyLength, string value)
|
||||
{{
|
||||
var pUB = pKeyBytes;
|
||||
{AppendSwitch(loop.Headers.Where(h => h.PrimaryHeader).GroupBy(x => x.Name.Length), loop.ClassName)}
|
||||
fixed (byte* ptr = &keyBytes[keyOffset])
|
||||
{{
|
||||
var pUB = ptr;
|
||||
{AppendSwitch(loop.Headers.Where(h => h.PrimaryHeader).GroupBy(x => x.Name.Length), loop.ClassName)}
|
||||
|
||||
AppendNonPrimaryHeaders(pKeyBytes, keyLength, value);
|
||||
AppendNonPrimaryHeaders(ptr, keyOffset, keyLength, value);
|
||||
}}
|
||||
}}
|
||||
|
||||
private unsafe void AppendNonPrimaryHeaders(byte* pKeyBytes, int keyLength, string value)
|
||||
private unsafe void AppendNonPrimaryHeaders(byte* pKeyBytes, int keyOffset, int keyLength, string value)
|
||||
{{
|
||||
var pUB = pKeyBytes;
|
||||
{AppendSwitch(loop.Headers.Where(h => !h.PrimaryHeader).GroupBy(x => x.Name.Length), loop.ClassName)}
|
||||
|
|
|
|||
Loading…
Reference in New Issue