mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-02-09 23:55:10 -05:00
Improve POST body debugging for playback endpoints
- Better logging to show what client sends vs what we forward - Log all headers when body is empty to help diagnose issues
This commit is contained in:
@@ -1546,28 +1546,32 @@ public class JellyfinController : ControllerBase
|
|||||||
|
|
||||||
// Read body using StreamReader with proper encoding
|
// Read body using StreamReader with proper encoding
|
||||||
string body;
|
string body;
|
||||||
using (var reader = new StreamReader(Request.Body, System.Text.Encoding.UTF8, leaveOpen: true))
|
using (var reader = new StreamReader(Request.Body, System.Text.Encoding.UTF8, detectEncodingFromByteOrderMarks: false, bufferSize: 1024, leaveOpen: true))
|
||||||
{
|
{
|
||||||
body = await reader.ReadToEndAsync();
|
body = await reader.ReadToEndAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset stream position after reading
|
// Reset stream position after reading so it can be read again if needed
|
||||||
Request.Body.Position = 0;
|
Request.Body.Position = 0;
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(body))
|
if (string.IsNullOrWhiteSpace(body))
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Empty POST body for {Path}, ContentLength={ContentLength}, ContentType={ContentType}",
|
_logger.LogWarning("Empty POST body received from client for {Path}, ContentLength={ContentLength}, ContentType={ContentType}",
|
||||||
fullPath, Request.ContentLength, Request.ContentType);
|
fullPath, Request.ContentLength, Request.ContentType);
|
||||||
|
|
||||||
|
// Log all headers to debug
|
||||||
|
_logger.LogWarning("Request headers: {Headers}",
|
||||||
|
string.Join(", ", Request.Headers.Select(h => $"{h.Key}={h.Value}")));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_logger.LogInformation("POST body for {Path}: {BodyLength} bytes, ContentType={ContentType}",
|
_logger.LogInformation("POST body received from client for {Path}: {BodyLength} bytes, ContentType={ContentType}",
|
||||||
fullPath, body.Length, Request.ContentType);
|
fullPath, body.Length, Request.ContentType);
|
||||||
|
|
||||||
// Always log body content for playback endpoints to debug the issue
|
// Always log body content for playback endpoints to debug the issue
|
||||||
if (fullPath.Contains("Playing", StringComparison.OrdinalIgnoreCase))
|
if (fullPath.Contains("Playing", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
_logger.LogInformation("POST body content: {Body}", body);
|
_logger.LogInformation("POST body content from client: {Body}", body);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user