diff options
| author | Erwin de Haan <EraYaN@users.noreply.github.com> | 2019-01-06 21:50:43 +0100 |
|---|---|---|
| committer | Erwin de Haan <EraYaN@users.noreply.github.com> | 2019-01-10 20:38:53 +0100 |
| commit | ec1f5dc317182582ebff843c9e8a4d5277405469 (patch) | |
| tree | 6514de336cc9aa94becb3fbd767285dfa61d0b1b /Emby.Server.Implementations/HttpServer/HttpResultFactory.cs | |
| parent | 3d867c2c46cec39b669bb8647efef677f32b8a8d (diff) | |
Mayor code cleanup
Add Argument*Exceptions now use proper nameof operators.
Added exception messages to quite a few Argument*Exceptions.
Fixed rethorwing to be proper syntax.
Added a ton of null checkes. (This is only a start, there are about 500 places that need proper null handling)
Added some TODOs to log certain exceptions.
Fix sln again.
Fixed all AssemblyInfo's and added proper copyright (where I could find them)
We live in *current year*.
Fixed the use of braces.
Fixed a ton of properties, and made a fair amount of functions static that should be and can be static.
Made more Methods that should be static static.
You can now use static to find bad functions!
Removed unused variable. And added one more proper XML comment.
Diffstat (limited to 'Emby.Server.Implementations/HttpServer/HttpResultFactory.cs')
| -rw-r--r-- | Emby.Server.Implementations/HttpServer/HttpResultFactory.cs | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs b/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs index 73b2afe64..05ec18642 100644 --- a/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs +++ b/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs @@ -1,4 +1,4 @@ -using MediaBrowser.Common.Extensions; +using MediaBrowser.Common.Extensions; using MediaBrowser.Controller.Net; using Microsoft.Extensions.Logging; using MediaBrowser.Model.Serialization; @@ -207,7 +207,7 @@ namespace Emby.Server.Implementations.HttpServer { if (result == null) { - throw new ArgumentNullException("result"); + throw new ArgumentNullException(nameof(result)); } if (responseHeaders == null) @@ -245,7 +245,7 @@ namespace Emby.Server.Implementations.HttpServer return GetCompressionType(request); } - private string GetCompressionType(IRequest request) + private static string GetCompressionType(IRequest request) { var acceptEncoding = request.Headers["Accept-Encoding"]; @@ -365,7 +365,7 @@ namespace Emby.Server.Implementations.HttpServer return _brotliCompressor.Compress(bytes); } - private byte[] Deflate(byte[] bytes) + private static byte[] Deflate(byte[] bytes) { // In .NET FX incompat-ville, you can't access compressed bytes without closing DeflateStream // Which means we must use MemoryStream since you have to use ToArray() on a closed Stream @@ -379,7 +379,7 @@ namespace Emby.Server.Implementations.HttpServer } } - private byte[] GZip(byte[] buffer) + private static byte[] GZip(byte[] buffer) { using (var ms = new MemoryStream()) using (var zipStream = new GZipStream(ms, CompressionMode.Compress)) @@ -398,7 +398,7 @@ namespace Emby.Server.Implementations.HttpServer : contentType.Split(';')[0].ToLower().Trim(); } - private string SerializeToXmlString(object from) + private static string SerializeToXmlString(object from) { using (var ms = new MemoryStream()) { @@ -453,7 +453,7 @@ namespace Emby.Server.Implementations.HttpServer { if (string.IsNullOrEmpty(path)) { - throw new ArgumentNullException("path"); + throw new ArgumentNullException(nameof(path)); } return GetStaticFileResult(requestContext, new StaticFileResultOptions @@ -471,7 +471,7 @@ namespace Emby.Server.Implementations.HttpServer if (string.IsNullOrEmpty(path)) { - throw new ArgumentNullException("path"); + throw new ArgumentNullException(nameof(path)); } if (fileShare != FileShareMode.Read && fileShare != FileShareMode.ReadWrite) @@ -661,7 +661,7 @@ namespace Emby.Server.Implementations.HttpServer /// <summary> /// Adds the expires header. /// </summary> - private void AddExpiresHeader(IDictionary<string, string> responseHeaders, string cacheKey, TimeSpan? cacheDuration) + private static void AddExpiresHeader(IDictionary<string, string> responseHeaders, string cacheKey, TimeSpan? cacheDuration) { if (cacheDuration.HasValue) { @@ -678,7 +678,7 @@ namespace Emby.Server.Implementations.HttpServer /// </summary> /// <param name="responseHeaders">The responseHeaders.</param> /// <param name="lastDateModified">The last date modified.</param> - private void AddAgeHeader(IDictionary<string, string> responseHeaders, DateTime? lastDateModified) + private static void AddAgeHeader(IDictionary<string, string> responseHeaders, DateTime? lastDateModified) { if (lastDateModified.HasValue) { @@ -771,7 +771,7 @@ namespace Emby.Server.Implementations.HttpServer /// </summary> /// <param name="date">The date.</param> /// <returns>DateTime.</returns> - private DateTime NormalizeDateForComparison(DateTime date) + private static DateTime NormalizeDateForComparison(DateTime date) { return new DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, date.Kind); } @@ -781,7 +781,7 @@ namespace Emby.Server.Implementations.HttpServer /// </summary> /// <param name="hasHeaders">The has options.</param> /// <param name="responseHeaders">The response headers.</param> - private void AddResponseHeaders(IHasHeaders hasHeaders, IEnumerable<KeyValuePair<string, string>> responseHeaders) + private static void AddResponseHeaders(IHasHeaders hasHeaders, IEnumerable<KeyValuePair<string, string>> responseHeaders) { foreach (var item in responseHeaders) { |
