mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-25 14:41:30 +00:00
Add logging for empty request body bug
This commit is contained in:
parent
ff470bcb34
commit
ecc1b844b1
1 changed files with 9 additions and 1 deletions
|
@ -39,6 +39,7 @@ public static partial class ControllerExtensions
|
||||||
|
|
||||||
public static async Task<string> ReadBodyAsync(this ControllerBase controller)
|
public static async Task<string> ReadBodyAsync(this ControllerBase controller)
|
||||||
{
|
{
|
||||||
|
controller.Request.Body.Position = 0;
|
||||||
StringBuilder builder = new();
|
StringBuilder builder = new();
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
|
@ -78,6 +79,14 @@ public static partial class ControllerExtensions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string finalString = builder.ToString();
|
||||||
|
if (finalString.Length != controller.Request.ContentLength)
|
||||||
|
{
|
||||||
|
Logger.Warn($"Failed to read entire body, contentType={controller.Request.ContentType}, " +
|
||||||
|
$"contentLen={controller.Request.ContentLength}, readLen={finalString.Length}",
|
||||||
|
LogArea.HTTP);
|
||||||
|
}
|
||||||
|
|
||||||
return builder.ToString();
|
return builder.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +95,6 @@ public static partial class ControllerExtensions
|
||||||
|
|
||||||
public static async Task<T?> DeserializeBody<T>(this ControllerBase controller, params string[] rootElements)
|
public static async Task<T?> DeserializeBody<T>(this ControllerBase controller, params string[] rootElements)
|
||||||
{
|
{
|
||||||
controller.Request.Body.Position = 0;
|
|
||||||
string bodyString = await controller.ReadBodyAsync();
|
string bodyString = await controller.ReadBodyAsync();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue