From 3b57860123a2a7a6c1d4db21b91de381abd61aca Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Mon, 4 May 2026 09:43:06 -0600 Subject: [PATCH] fix: correct response status description in LoginRequestHandler and improve error logging in ServeDebugAppRequestHandler --- .../Web/RequestHandlers/LoginRequestHandler.cs | 5 ++--- .../ServeDebugAppRequestHandler.cs | 15 ++++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/PepperDash.Essentials.Core/Web/RequestHandlers/LoginRequestHandler.cs b/src/PepperDash.Essentials.Core/Web/RequestHandlers/LoginRequestHandler.cs index 8d724f11..5a4b7df7 100644 --- a/src/PepperDash.Essentials.Core/Web/RequestHandlers/LoginRequestHandler.cs +++ b/src/PepperDash.Essentials.Core/Web/RequestHandlers/LoginRequestHandler.cs @@ -71,7 +71,6 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers { context.Response.StatusCode = 401; context.Response.StatusDescription = "Bad Request"; - context.Response.StatusDescription = "Unauthorized"; context.Response.ContentType = "application/json"; context.Response.ContentEncoding = System.Text.Encoding.UTF8; context.Response.Write(JsonConvert.SerializeObject(new { Error = "Unauthorized" }, Formatting.Indented), false); @@ -80,8 +79,8 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers } if (!token.Valid) - { - context.Response.StatusCode = 401; + { + context.Response.StatusCode = 401; context.Response.StatusDescription = "Unauthorized"; context.Response.End(); diff --git a/src/PepperDash.Essentials.Core/Web/RequestHandlers/ServeDebugAppRequestHandler.cs b/src/PepperDash.Essentials.Core/Web/RequestHandlers/ServeDebugAppRequestHandler.cs index 3e48859e..2092c735 100644 --- a/src/PepperDash.Essentials.Core/Web/RequestHandlers/ServeDebugAppRequestHandler.cs +++ b/src/PepperDash.Essentials.Core/Web/RequestHandlers/ServeDebugAppRequestHandler.cs @@ -125,7 +125,7 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers if (TextExtensions.Contains(ext)) { string content; - using (var reader = new StreamReader(resolvedCandidate)) + using (var reader = new StreamReader(resolvedCandidate, Encoding.UTF8)) content = reader.ReadToEnd(); context.Response.ContentEncoding = Encoding.UTF8; @@ -141,10 +141,11 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers } catch (Exception ex) { - Debug.LogMessage(LogEventLevel.Error, - "ServeDebugAppRequestHandler: Unhandled error serving '{rawUrl:l}': {ex}", - context.Request.RawUrl, ex.Message); - try { SendResponse(context, 500, "Internal Server Error"); } catch { /* best-effort */ } + Debug.LogMessage(LogEventLevel.Error, ex, + "ServeDebugAppRequestHandler: Unhandled error serving '{rawUrl:l}'", + context.Request.RawUrl); + try { SendResponse(context, 500, "Internal Server Error"); } + catch { /* best-effort */ } } } @@ -189,8 +190,8 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers } catch (Exception ex) { - Debug.LogMessage(LogEventLevel.Error, - "ServeDebugAppRequestHandler: Error resolving HTML debug path: {ex}", ex.Message); + Debug.LogMessage(LogEventLevel.Error, ex, + "ServeDebugAppRequestHandler: Error resolving HTML debug path"); return null; } }