Don't log contentLength warnings if the header is null

This commit is contained in:
Slendy 2023-04-07 21:00:08 -05:00
commit a706ef6836
No known key found for this signature in database
GPG key ID: 7288D68361B91428

View file

@ -29,7 +29,7 @@ public static partial class ControllerExtensions
public static async Task<string> ReadBodyAsync(this ControllerBase controller)
{
byte[] bodyBytes = await controller.Request.BodyReader.ReadAllAsync();
if (bodyBytes.Length != controller.Request.ContentLength)
if (controller.Request.ContentLength != null && bodyBytes.Length != controller.Request.ContentLength)
{
Logger.Warn($"Failed to read entire body, contentType={controller.Request.ContentType}, " +
$"contentLen={controller.Request.ContentLength}, readLen={bodyBytes.Length}",