Merge remote-tracking branch 'origin/patch/3.5.2' into patch/3.5.2
This commit is contained in:
commit
58cede9ca1
|
|
@ -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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue