From 48a035186227b8d297a463de3cb0afbeb4c5201d Mon Sep 17 00:00:00 2001 From: Josh Patra Date: Fri, 30 Jan 2026 00:45:16 -0500 Subject: [PATCH] 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 --- allstarr/Controllers/JellyfinController.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/allstarr/Controllers/JellyfinController.cs b/allstarr/Controllers/JellyfinController.cs index 1b0f7ce..3c3b4bd 100644 --- a/allstarr/Controllers/JellyfinController.cs +++ b/allstarr/Controllers/JellyfinController.cs @@ -1546,28 +1546,32 @@ public class JellyfinController : ControllerBase // Read body using StreamReader with proper encoding 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(); } - // Reset stream position after reading + // Reset stream position after reading so it can be read again if needed Request.Body.Position = 0; 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); + + // Log all headers to debug + _logger.LogWarning("Request headers: {Headers}", + string.Join(", ", Request.Headers.Select(h => $"{h.Key}={h.Value}"))); } 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); // Always log body content for playback endpoints to debug the issue if (fullPath.Contains("Playing", StringComparison.OrdinalIgnoreCase)) { - _logger.LogInformation("POST body content: {Body}", body); + _logger.LogInformation("POST body content from client: {Body}", body); } }