From e9ebe07ecc38726ad7f14c8d38131ce101a28651 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 26 May 2020 16:36:54 +0200 Subject: [PATCH 1/2] Don't send Exception message in Production Environment --- Emby.Server.Implementations/HttpServer/HttpListenerHost.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs index 7de4f168c1..9e8c3eb9be 100644 --- a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -230,6 +230,12 @@ namespace Emby.Server.Implementations.HttpServer httpRes.StatusCode = statusCode; + if (!_hostEnvironment.IsDevelopment()) + { + await httpRes.WriteAsync("Error processing request.").ConfigureAwait(false); + return; + } + var errContent = NormalizeExceptionMessage(ex) ?? string.Empty; httpRes.ContentType = "text/plain"; httpRes.ContentLength = errContent.Length; From 37a4cc599ba54421f38811e6b2e6ff76fb5f45c0 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 2 Jun 2020 15:05:57 +0200 Subject: [PATCH 2/2] Remove duplicate code Co-authored-by: Vasily --- .../HttpServer/HttpListenerHost.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs index 9e8c3eb9be..b1a5c6dc5e 100644 --- a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -230,13 +230,9 @@ namespace Emby.Server.Implementations.HttpServer httpRes.StatusCode = statusCode; - if (!_hostEnvironment.IsDevelopment()) - { - await httpRes.WriteAsync("Error processing request.").ConfigureAwait(false); - return; - } - - var errContent = NormalizeExceptionMessage(ex) ?? string.Empty; + var errContent = _hostEnvironment.IsDevelopment() + ? (NormalizeExceptionMessage(ex) ?? string.Empty) + : "Error processing request."; httpRes.ContentType = "text/plain"; httpRes.ContentLength = errContent.Length; await httpRes.WriteAsync(errContent).ConfigureAwait(false);