Browse Source

Set response length and mime type correctly when reporting an error

Vasily 5 years ago
parent
commit
33b69a7099
1 changed files with 4 additions and 2 deletions
  1. 4 2
      Emby.Server.Implementations/HttpServer/HttpListenerHost.cs

+ 4 - 2
Emby.Server.Implementations/HttpServer/HttpListenerHost.cs

@@ -233,8 +233,10 @@ namespace Emby.Server.Implementations.HttpServer
                 var statusCode = GetStatusCode(ex);
                 var statusCode = GetStatusCode(ex);
                 httpRes.StatusCode = statusCode;
                 httpRes.StatusCode = statusCode;
 
 
-                httpRes.ContentType = "text/html";
-                await httpRes.WriteAsync(NormalizeExceptionMessage(ex.Message)).ConfigureAwait(false);
+                var errContent = NormalizeExceptionMessage(ex.Message);
+                httpRes.ContentType = "text/plain";
+                httpRes.ContentLength = errContent.Length;
+                await httpRes.WriteAsync(errContent).ConfigureAwait(false);
             }
             }
             catch (Exception errorEx)
             catch (Exception errorEx)
             {
             {