From e6b6371cb042cdc0796e490f09b0fcd4c13a2b73 Mon Sep 17 00:00:00 2001 From: Assaf Tirangel Date: Mon, 25 Dec 2023 15:57:21 +0200 Subject: [PATCH] Add support for PATCH in HttpConnection.ConvertHttpMethod Signed-off-by: Assaf Tirangel --- .../Connection/HttpConnection.cs | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/OpenSearch.Net/Connection/HttpConnection.cs b/src/OpenSearch.Net/Connection/HttpConnection.cs index 57c63a34af..762ad0032a 100644 --- a/src/OpenSearch.Net/Connection/HttpConnection.cs +++ b/src/OpenSearch.Net/Connection/HttpConnection.cs @@ -27,7 +27,6 @@ */ using System; -using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; @@ -430,19 +429,17 @@ private static async Task SetContentAsync(HttpRequestMessage message, RequestDat } } - private static System.Net.Http.HttpMethod ConvertHttpMethod(HttpMethod httpMethod) - { - switch (httpMethod) + private static System.Net.Http.HttpMethod ConvertHttpMethod(HttpMethod httpMethod) => + httpMethod switch { - case HttpMethod.GET: return System.Net.Http.HttpMethod.Get; - case HttpMethod.POST: return System.Net.Http.HttpMethod.Post; - case HttpMethod.PUT: return System.Net.Http.HttpMethod.Put; - case HttpMethod.DELETE: return System.Net.Http.HttpMethod.Delete; - case HttpMethod.HEAD: return System.Net.Http.HttpMethod.Head; - default: - throw new ArgumentException("Invalid value for HttpMethod", nameof(httpMethod)); - } - } + HttpMethod.GET => System.Net.Http.HttpMethod.Get, + HttpMethod.POST => System.Net.Http.HttpMethod.Post, + HttpMethod.PUT => System.Net.Http.HttpMethod.Put, + HttpMethod.DELETE => System.Net.Http.HttpMethod.Delete, + HttpMethod.HEAD => System.Net.Http.HttpMethod.Head, + HttpMethod.PATCH => new System.Net.Http.HttpMethod("PATCH"), + _ => throw new ArgumentException("Invalid value for HttpMethod", nameof(httpMethod)) + }; internal static int GetClientKey(RequestData requestData) {