Merge remote-tracking branch 'origin/patch/3.5.2' into patch/3.5.2

This commit is contained in:
Sipke Schoorstra 2025-10-08 21:15:48 +02:00
commit 58cede9ca1
No known key found for this signature in database
GPG key ID: 5C10502B28A4268F

View file

@ -30,19 +30,24 @@ internal class PostEndpoint(
{
PostRequest? request = null;
if (HttpContext.Request.ContentLength > 0 && (HttpContext.Request.ContentType?.Contains("application/json") ?? true))
if (HttpContext.Request.ContentType?.Contains("application/json") ?? false)
{
try
using var reader = new StreamReader(HttpContext.Request.Body);
var body = await reader.ReadToEndAsync();
if (!string.IsNullOrWhiteSpace(body))
{
request = await JsonSerializer.DeserializeAsync<PostRequest>(HttpContext.Request.Body,
new JsonSerializerOptions
try
{
PropertyNameCaseInsensitive = true
}, cancellationToken: cancellationToken);
}
catch
{
AddError("Invalid request body.");
request = JsonSerializer.Deserialize<PostRequest>(body, new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true
});
}
catch
{
AddError("Invalid request body.");
}
}
}