The Free Software Media System - Server Backend & API
Merge branch 'dev' into cleanup
Bond-009900dc851e6c8
diff --cc Emby.Server.Implementations/HttpServer/HttpListenerHost.csindex 91b2e9ded6,8219b85a2e..fb5f53367f--- a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs+++ b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs@@@ -1,4 -1,7 +1,3 @@@- -using MediaBrowser.Common.Extensions;-using MediaBrowser.Controller.Configuration;-using MediaBrowser.Controller.Net;-using Microsoft.Extensions.Logging;using System;using System.Collections.Generic;using System.Globalization;@@@ -9,15 -11,9 +8,14 @@@ using System.Reflectionusing System.Text;using System.Threading;using System.Threading.Tasks;+using Emby.Server.Implementations.Net;using Emby.Server.Implementations.Services;+using MediaBrowser.Common.Extensions;using MediaBrowser.Common.Net;- using MediaBrowser.Common.Security;using MediaBrowser.Controller;+using MediaBrowser.Controller.Configuration;+using MediaBrowser.Controller.Net;+using MediaBrowser.Model.Events;using MediaBrowser.Model.Extensions;using MediaBrowser.Model.Serialization;using MediaBrowser.Model.Services;@@@ -205,17 -206,27 +203,16 @@@ namespace Emby.Server.Implementations.Hprivate int GetStatusCode(Exception ex){- if (ex is ArgumentException)+ switch (ex){- return 400;+ case ArgumentException _: return 400;+ case SecurityException _: return 401;- case PaymentRequiredException _: return 402;+ case DirectoryNotFoundException _:+ case FileNotFoundException _:+ case ResourceNotFoundException _: return 404;+ case RemoteServiceUnavailableException _: return 502;+ default: return 500;}-- var exceptionType = ex.GetType();-- int statusCode;- if (!_mapExceptionToStatusCode.TryGetValue(exceptionType, out statusCode))- {- if (ex is DirectoryNotFoundException)- {- statusCode = 404;- }- else- {- statusCode = 500;- }- }-- return statusCode;}private async Task ErrorHandler(Exception ex, IRequest httpReq, bool logExceptionStackTrace, bool logExceptionMessage)@@@ -315,11 -326,18 +312,11 @@@{var extension = GetExtension(url);- if (string.IsNullOrEmpty(extension) || !_skipLogExtensions.ContainsKey(extension))- {- if (string.IsNullOrEmpty(localPath) || localPath.IndexOf("system/ping", StringComparison.OrdinalIgnoreCase) == -1)- {- return true;- }- }-- return false;+ return ((string.IsNullOrEmpty(extension) || !_skipLogExtensions.Contains(extension))+ && (string.IsNullOrEmpty(localPath) || localPath.IndexOf("system/ping", StringComparison.OrdinalIgnoreCase) == -1));}- private string GetExtension(string url)+ private static string GetExtension(string url){var parts = url.Split(new[] { '?' }, 2);diff --cc Emby.Server.Implementations/HttpServer/RangeRequestWriter.csindex 795f96f2c2,f08112f9ca..ef47a7ca97--- a/Emby.Server.Implementations/HttpServer/RangeRequestWriter.cs+++ b/Emby.Server.Implementations/HttpServer/RangeRequestWriter.cs@@@ -217,8 -217,10 +214,8 @@@ namespace Emby.Server.Implementations.Hpublic HttpStatusCode StatusCode{- get { return (HttpStatusCode)Status; }- set { Status = (int)value; }+ get => (HttpStatusCode)Status;+ set => Status = (int)value;}-- public string StatusDescription { get; set; }}}