From d11098c0ba9a66c13790e533e8223766c0ff44f6 Mon Sep 17 00:00:00 2001 From: Weihan Li Date: Fri, 23 May 2025 18:01:13 +0800 Subject: [PATCH 1/3] add HttpMethod.Query --- src/libraries/System.Net.Http/ref/System.Net.Http.cs | 1 + src/libraries/System.Net.Http/src/System/Net/Http/HttpMethod.cs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/libraries/System.Net.Http/ref/System.Net.Http.cs b/src/libraries/System.Net.Http/ref/System.Net.Http.cs index 2a7f27d96be35d..c0931763c8fb47 100644 --- a/src/libraries/System.Net.Http/ref/System.Net.Http.cs +++ b/src/libraries/System.Net.Http/ref/System.Net.Http.cs @@ -243,6 +243,7 @@ public HttpMethod(string method) { } public static System.Net.Http.HttpMethod Patch { get { throw null; } } public static System.Net.Http.HttpMethod Post { get { throw null; } } public static System.Net.Http.HttpMethod Put { get { throw null; } } + public static System.Net.Http.HttpMethod Query { get { throw null; } } public static System.Net.Http.HttpMethod Trace { get { throw null; } } public bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] System.Net.Http.HttpMethod? other) { throw null; } public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; } diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/HttpMethod.cs b/src/libraries/System.Net.Http/src/System/Net/Http/HttpMethod.cs index fb3c7fe5ea43f4..478beb5e90b01c 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/HttpMethod.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/HttpMethod.cs @@ -19,6 +19,7 @@ public partial class HttpMethod : IEquatable public static HttpMethod Options { get; } = new("OPTIONS", H3StaticTable.MethodOptions); public static HttpMethod Trace { get; } = new("TRACE", http3StaticTableIndex: -1); public static HttpMethod Patch { get; } = new("PATCH", http3StaticTableIndex: -1); + public static HttpMethod Query { get; } = new("QUERY", http3StaticTableIndex: -1); /// Gets the HTTP CONNECT protocol method. /// The HTTP CONNECT method. @@ -106,6 +107,7 @@ public static HttpMethod Parse(ReadOnlySpan method) => 4 => Post, _ => Patch, }, + 'q' => Query, 't' => Trace, _ => null, }; From 2c2b0a6dfc5c23fa6eb6348afce3df91da5e1762 Mon Sep 17 00:00:00 2001 From: Weihan Li Date: Mon, 26 May 2025 20:58:48 +0800 Subject: [PATCH 2/3] docs: add comment for the query method --- .../System.Net.Http/src/System/Net/Http/HttpMethod.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/HttpMethod.cs b/src/libraries/System.Net.Http/src/System/Net/Http/HttpMethod.cs index 478beb5e90b01c..799ec9fca6a5b9 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/HttpMethod.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/HttpMethod.cs @@ -19,6 +19,9 @@ public partial class HttpMethod : IEquatable public static HttpMethod Options { get; } = new("OPTIONS", H3StaticTable.MethodOptions); public static HttpMethod Trace { get; } = new("TRACE", http3StaticTableIndex: -1); public static HttpMethod Patch { get; } = new("PATCH", http3StaticTableIndex: -1); + + /// Gets the HTTP QUERY protocol method. + /// The HTTP QUERY method. public static HttpMethod Query { get; } = new("QUERY", http3StaticTableIndex: -1); /// Gets the HTTP CONNECT protocol method. From a67de51216350f17ec58d1fd94b359875761fa84 Mon Sep 17 00:00:00 2001 From: Weihan Li Date: Mon, 26 May 2025 21:03:52 +0800 Subject: [PATCH 3/3] test: update tests for query method --- .../System.Net.Http/tests/FunctionalTests/HttpMethodTest.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libraries/System.Net.Http/tests/FunctionalTests/HttpMethodTest.cs b/src/libraries/System.Net.Http/tests/FunctionalTests/HttpMethodTest.cs index 9911fa10bc0222..c85444be7d10a6 100644 --- a/src/libraries/System.Net.Http/tests/FunctionalTests/HttpMethodTest.cs +++ b/src/libraries/System.Net.Http/tests/FunctionalTests/HttpMethodTest.cs @@ -37,6 +37,7 @@ public void StaticProperties_VerifyValues_PropertyNameMatchesHttpMethodName() Assert.Equal("HEAD", HttpMethod.Head.Method); Assert.Equal("OPTIONS", HttpMethod.Options.Method); Assert.Equal("TRACE", HttpMethod.Trace.Method); + Assert.Equal("QUERY", HttpMethod.Query.Method); } [Fact] @@ -160,6 +161,7 @@ public static IEnumerable Parse_UsesKnownInstances_MemberData() yield return new object[] { HttpMethod.Patch, nameof(HttpMethod.Patch) }; yield return new object[] { HttpMethod.Post, nameof(HttpMethod.Post) }; yield return new object[] { HttpMethod.Put, nameof(HttpMethod.Put) }; + yield return new object[] { HttpMethod.Query, nameof(HttpMethod.Query) }; yield return new object[] { HttpMethod.Trace, nameof(HttpMethod.Trace) }; }