Fixups to signature of `HttpCommunication.ContentObjectFor` method

fixes 41547824a
This commit is contained in:
YoshiRulz 2025-01-17 08:25:12 +10:00
parent 1437bc3a98
commit d8508acb69
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
1 changed files with 9 additions and 10 deletions

View File

@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Net.Http;
using System.Threading.Tasks;
@ -11,6 +10,15 @@ namespace BizHawk.Client.Common
{
private const string MIME_FORM_URLENC = "application/x-www-form-urlencoded";
public static HttpContent ContentObjectFor(string payload, string mimeType)
=> mimeType switch
{
MIME_FORM_URLENC => new FormUrlEncodedContent([ new("payload", payload) ]),
#pragma warning disable BHI1005 // exception type
_ => throw new NotImplementedException()
#pragma warning restore BHI1005
};
private readonly HttpClient _client = new HttpClient();
private readonly Func<byte[]> _takeScreenshotCallback;
@ -33,15 +41,6 @@ namespace BizHawk.Client.Common
_client.DefaultRequestHeaders.UserAgent.ParseAdd(VersionInfo.UserAgentEscaped);
}
private HttpContent ContentObjectFor(string payload, [ConstantExpected] string mimeType)
=> mimeType switch
{
MIME_FORM_URLENC => new FormUrlEncodedContent([ new("payload", payload) ]),
#pragma warning disable BHI1005 // exception type
_ => throw new NotImplementedException()
#pragma warning restore BHI1005
};
public string ExecGet(string url = null) => Get(url ?? GetUrl).Result;
/// <inheritdoc cref="ExecPostAsForm"/>