Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions src/Servers/Kestrel/Core/src/Internal/Http/HttpParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,19 @@ private void ParseRequestLine(TRequestHandler handler, ReadOnlySpan<byte> reques
offset++;

// Find end of path and if path is encoded
for (; (uint)offset < (uint)requestLine.Length; offset++)
var index = requestLine.Slice(offset).IndexOfAny(ByteSpace, ByteQuestionMark, BytePercentage);
if (index >= 0)
{
ch = requestLine[offset];
if (ch == ByteSpace || ch == ByteQuestionMark)
{
// End of path
break;
}
else if (ch == BytePercentage)
if (requestLine[offset + index] == BytePercentage)
{
pathEncoded = true;
offset += index;
// Found an encoded character, now just search for end of path
index = requestLine.Slice(offset).IndexOfAny(ByteSpace, ByteQuestionMark);
}

offset += index;
ch = requestLine[offset];
}

var path = new TargetOffsetPathLength(targetStart, length: offset - targetStart, pathEncoded);
Expand Down