Skip to content

Commit

Permalink
Add support for PATCH in HttpConnection.ConvertHttpMethod
Browse files Browse the repository at this point in the history
Signed-off-by: Assaf Tirangel <[email protected]>
  • Loading branch information
Assaf Tirangel committed Dec 26, 2023
1 parent a9f9eb4 commit e6b6371
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions src/OpenSearch.Net/Connection/HttpConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
*/

using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit e6b6371

Please sign in to comment.