Browse Source

ASP.NET Core flip Json and plaintext (#5672)

Ben Adams 5 years ago
parent
commit
19b136f3bc

+ 13 - 8
frameworks/CSharp/aspnetcore/PlatformBenchmarks/BenchmarkApplication.cs

@@ -60,22 +60,28 @@ namespace PlatformBenchmarks
 #endif
 #endif
         public void OnStartLine(HttpMethod method, HttpVersion version, Span<byte> target, Span<byte> path, Span<byte> query, Span<byte> customMethod, bool pathEncoded)
         public void OnStartLine(HttpMethod method, HttpVersion version, Span<byte> target, Span<byte> path, Span<byte> query, Span<byte> customMethod, bool pathEncoded)
         {
         {
-            var requestType = RequestType.NotRecognized;
+#if !DATABASE
             if (method == HttpMethod.Get)
             if (method == HttpMethod.Get)
             {
             {
-#if !DATABASE
                 if (path.Length >= 2 && path[0] == '/')
                 if (path.Length >= 2 && path[0] == '/')
                 {
                 {
-                    if (path[1] == 'j')
+                    if (path[1] == 'p')
                     {
                     {
-                        requestType = RequestType.Json;
+                        _requestType = RequestType.PlainText;
+                        return;
                     }
                     }
-                    else if (path[1] == 'p')
+                    if (path[1] == 'j')
                     {
                     {
-                        requestType = RequestType.PlainText;
+                        _requestType = RequestType.Json;
+                        return;
                     }
                     }
                 }
                 }
+            }
+            _requestType = RequestType.NotRecognized;
 #else
 #else
+            var requestType = RequestType.NotRecognized;
+            if (method == HttpMethod.Get)
+            {
                 var pathLength = path.Length;
                 var pathLength = path.Length;
                 if (Paths.SingleQuery.Length <= pathLength && path.StartsWith(Paths.SingleQuery))
                 if (Paths.SingleQuery.Length <= pathLength && path.StartsWith(Paths.SingleQuery))
                 {
                 {
@@ -95,10 +101,9 @@ namespace PlatformBenchmarks
                     _queries = ParseQueries(path, Paths.MultipleQueries.Length);
                     _queries = ParseQueries(path, Paths.MultipleQueries.Length);
                     requestType = RequestType.MultipleQueries;
                     requestType = RequestType.MultipleQueries;
                 }
                 }
-#endif
             }
             }
-
             _requestType = requestType;
             _requestType = requestType;
+#endif
         }
         }