Skip to content

Commit 9732b70

Browse files
authored
CoreRT update (#5670)
1 parent 84f88d5 commit 9732b70

File tree

1 file changed

+32
-19
lines changed

1 file changed

+32
-19
lines changed

frameworks/CSharp/aspnetcore-corert/PlatformBenchmarks/BenchmarkApplication.cs

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
5+
using System.Buffers.Binary;
56
using System.Buffers.Text;
67
using System.IO.Pipelines;
78
using System.Threading.Tasks;
@@ -51,6 +52,8 @@ public static class Paths
5152
public readonly static AsciiString Plaintext = "/p";
5253
public readonly static AsciiString Updates = "/updates/queries=";
5354
public readonly static AsciiString MultipleQueries = "/queries/queries=";
55+
public const ushort JsonPath = 0x6a2f;
56+
public const ushort PlaintextPath = 0x702f;
5457
}
5558

5659
private RequestType _requestType;
@@ -59,45 +62,55 @@ public static class Paths
5962
#endif
6063
public void OnStartLine(HttpMethod method, HttpVersion version, Span<byte> target, Span<byte> path, Span<byte> query, Span<byte> customMethod, bool pathEncoded)
6164
{
62-
var requestType = RequestType.NotRecognized;
63-
if (method == HttpMethod.Get)
64-
{
65+
6566
#if !DATABASE
66-
if (path.Length >= 2 && path[0] == '/')
67+
if (method == HttpMethod.Get && BinaryPrimitives.TryReadUInt16LittleEndian(path, out var value))
68+
{
69+
if (value == Paths.PlaintextPath)
6770
{
68-
if (path[1] == 'j')
69-
{
70-
requestType = RequestType.Json;
71-
}
72-
else if (path[1] == 'p')
73-
{
74-
requestType = RequestType.PlainText;
75-
}
71+
_requestType = RequestType.PlainText;
72+
return;
7673
}
74+
else if (value == Paths.JsonPath)
75+
{
76+
_requestType = RequestType.Json;
77+
return;
78+
}
79+
}
80+
81+
_requestType = RequestType.NotRecognized;
7782
#else
83+
if (method == HttpMethod.Get)
84+
{
7885
var pathLength = path.Length;
7986
if (Paths.SingleQuery.Length <= pathLength && path.StartsWith(Paths.SingleQuery))
8087
{
81-
requestType = RequestType.SingleQuery;
88+
_requestType = RequestType.SingleQuery;
8289
}
8390
else if (Paths.Fortunes.Length <= pathLength && path.StartsWith(Paths.Fortunes))
8491
{
85-
requestType = RequestType.Fortunes;
92+
_requestType = RequestType.Fortunes;
8693
}
8794
else if (Paths.Updates.Length <= pathLength && path.StartsWith(Paths.Updates))
8895
{
8996
_queries = ParseQueries(path, Paths.Updates.Length);
90-
requestType = RequestType.Updates;
97+
_requestType = RequestType.Updates;
9198
}
9299
else if (Paths.MultipleQueries.Length <= pathLength && path.StartsWith(Paths.MultipleQueries))
93100
{
94101
_queries = ParseQueries(path, Paths.MultipleQueries.Length);
95-
requestType = RequestType.MultipleQueries;
102+
_requestType = RequestType.MultipleQueries;
103+
}
104+
else
105+
{
106+
_requestType = RequestType.NotRecognized;
96107
}
97-
#endif
98108
}
99-
100-
_requestType = requestType;
109+
else
110+
{
111+
_requestType = RequestType.NotRecognized;
112+
}
113+
#endif
101114
}
102115

103116

0 commit comments

Comments
 (0)