The Free Software Media System - Server Backend & API
Fix more warnings
Bond-00938d9eeffbe2d
diff --git a/Jellyfin.Server/SocketSharp/RequestMono.cs b/Jellyfin.Server/SocketSharp/RequestMono.csindex f09197fb35..e39ed30ea0 100644--- a/Jellyfin.Server/SocketSharp/RequestMono.cs+++ b/Jellyfin.Server/SocketSharp/RequestMono.cs@@ -11,7 +11,7 @@ namespace Jellyfin.SocketSharp{public partial class WebSocketSharpRequest : IHttpRequest{- static internal string GetParameter(string header, string attr)+ internal static string GetParameter(string header, string attr){int ap = header.IndexOf(attr);if (ap == -1)@@ -40,7 +40,7 @@ namespace Jellyfin.SocketSharpreturn header.Substring(ap + 1, end - ap - 1);}- async Task LoadMultiPart(WebROCollection form)+ private async Task LoadMultiPart(WebROCollection form){string boundary = GetParameter(ContentType, "; boundary=");if (boundary == null)@@ -50,8 +50,8 @@ namespace Jellyfin.SocketSharpusing (var requestStream = InputStream){- //DB: 30/01/11 - Hack to get around non-seekable stream and received HTTP request- //Not ending with \r\n?+ // DB: 30/01/11 - Hack to get around non-seekable stream and received HTTP request+ // Not ending with \r\n?var ms = new MemoryStream(32 * 1024);await requestStream.CopyToAsync(ms).ConfigureAwait(false);@@ -62,9 +62,9 @@ namespace Jellyfin.SocketSharpinput.Position = 0;// Uncomment to debug- //var content = new StreamReader(ms).ReadToEnd();- //Console.WriteLine(boundary + "::" + content);- //input.Position = 0;+ // var content = new StreamReader(ms).ReadToEnd();+ // Console.WriteLine(boundary + "::" + content);+ // input.Position = 0;var multi_part = new HttpMultipart(input, boundary, ContentEncoding);@@ -111,7 +111,7 @@ namespace Jellyfin.SocketSharp// Setting this before calling the validator prevents// possible endless recursionchecked_form = true;- ValidateNameValueCollection ("Form", query_string_nvc, RequestValidationSource.Form);+ ValidateNameValueCollection("Form", query_string_nvc, RequestValidationSource.Form);} else#endifif (validate_form && !checked_form)@@ -130,7 +130,7 @@ namespace Jellyfin.SocketSharpprotected bool validate_cookies, validate_query_string, validate_form;protected bool checked_cookies, checked_query_string, checked_form;- static void ThrowValidationException(string name, string key, string value)+ private static void ThrowValidationException(string name, string key, string value){string v = "\"" + value + "\"";if (v.Length > 20)@@ -144,7 +144,7 @@ namespace Jellyfin.SocketSharpthrow new Exception(msg);}- static void ValidateNameValueCollection(string name, QueryParamCollection coll)+ private static void ValidateNameValueCollection(string name, QueryParamCollection coll){if (coll == null){@@ -209,7 +209,7 @@ namespace Jellyfin.SocketSharpvalidate_form = true;}- bool IsContentType(string ct, bool starts_with)+ private bool IsContentType(string ct, bool starts_with){if (ct == null || ContentType == null){@@ -224,7 +224,7 @@ namespace Jellyfin.SocketSharpreturn string.Equals(ContentType, ct, StringComparison.OrdinalIgnoreCase);}- async Task LoadWwwForm(WebROCollection form)+ private async Task LoadWwwForm(WebROCollection form){using (var input = InputStream){@@ -280,7 +280,7 @@ namespace Jellyfin.SocketSharp}}- static void AddRawKeyValue(WebROCollection form, StringBuilder key, StringBuilder value)+ private static void AddRawKeyValue(WebROCollection form, StringBuilder key, StringBuilder value){form.Add(WebUtility.UrlDecode(key.ToString()), WebUtility.UrlDecode(value.ToString()));@@ -288,9 +288,9 @@ namespace Jellyfin.SocketSharpvalue.Length = 0;}- Dictionary<string, HttpPostedFile> files;+ private Dictionary<string, HttpPostedFile> files;- class WebROCollection : QueryParamCollection+ private class WebROCollection : QueryParamCollection{public override string ToString(){@@ -317,16 +317,16 @@ namespace Jellyfin.SocketSharppublic sealed class HttpPostedFile{- string name;- string content_type;- Stream stream;+ private string name;+ private string content_type;+ private Stream stream;- class ReadSubStream : Stream+ private class ReadSubStream : Stream{- Stream s;- long offset;- long end;- long position;+ private Stream s;+ private long offset;+ private long end;+ private long position;public ReadSubStream(Stream s, long offset, long length){@@ -429,7 +429,7 @@ namespace Jellyfin.SocketSharpreal = position + d;break;default:- throw new ArgumentException();+ throw new ArgumentException(nameof(origin));}long virt = real - offset;@@ -491,7 +491,7 @@ namespace Jellyfin.SocketSharppublic Stream InputStream => stream;}- class Helpers+ private class Helpers{public static readonly CultureInfo InvariantCulture = CultureInfo.InvariantCulture;}@@ -614,7 +614,7 @@ namespace Jellyfin.SocketSharpprivate static string GetContentDispositionAttribute(string l, string name){- int idx = l.IndexOf(name + "=\"");+ int idx = l.IndexOf(name + "=\"", StringComparison.Ordinal);if (idx < 0){return null;@@ -637,7 +637,7 @@ namespace Jellyfin.SocketSharpprivate string GetContentDispositionAttributeWithEncoding(string l, string name){- int idx = l.IndexOf(name + "=\"");+ int idx = l.IndexOf(name + "=\"", StringComparison.Ordinal);if (idx < 0){return null;@@ -669,11 +669,12 @@ namespace Jellyfin.SocketSharp{try{- string line = ReadLine();- while (line == string.Empty)+ string line;+ do{line = ReadLine();}+ while (line.Length == 0);if (line[0] != '-' || line[1] != '-'){diff --git a/Jellyfin.Server/SocketSharp/WebSocketSharpRequest.cs b/Jellyfin.Server/SocketSharp/WebSocketSharpRequest.csindex 2863106f89..38e8d9699e 100644--- a/Jellyfin.Server/SocketSharp/WebSocketSharpRequest.cs+++ b/Jellyfin.Server/SocketSharp/WebSocketSharpRequest.cs@@ -80,8 +80,8 @@ namespace Jellyfin.SocketSharpprivate string remoteIp;public string RemoteIp =>remoteIp ??- (remoteIp = (CheckBadChars(XForwardedFor)) ??- (NormalizeIp(CheckBadChars(XRealIp)) ??+ (remoteIp = CheckBadChars(XForwardedFor) ??+ NormalizeIp(CheckBadChars(XRealIp) ??(request.RemoteEndPoint != null ? NormalizeIp(request.RemoteEndPoint.Address.ToString()) : null)));private static readonly char[] HttpTrimCharacters = new char[] { (char)0x09, (char)0xA, (char)0xB, (char)0xC, (char)0xD, (char)0x20 };@@ -201,7 +201,7 @@ namespace Jellyfin.SocketSharpreturn specifiedContentType;}- var serverDefaultContentType = "application/json";+ const string serverDefaultContentType = "application/json";var acceptContentTypes = httpReq.AcceptTypes;string defaultContentType = null;@@ -211,7 +211,7 @@ namespace Jellyfin.SocketSharp}var acceptsAnything = false;- var hasDefaultContentType = !string.IsNullOrEmpty(defaultContentType);+ var hasDefaultContentType = defaultContentType != null;if (acceptContentTypes != null){foreach (var acceptsType in acceptContentTypes)@@ -311,7 +311,7 @@ namespace Jellyfin.SocketSharpreturn null;}- var pos = strVal.IndexOf(needle);+ var pos = strVal.IndexOf(needle, StringComparison.Ordinal);return pos == -1 ? strVal : strVal.Substring(0, pos);}@@ -397,6 +397,7 @@ namespace Jellyfin.SocketSharp}}}+if (!pathRootFound){return null;@@ -507,10 +508,10 @@ namespace Jellyfin.SocketSharppublic static string NormalizePathInfo(string pathInfo, string handlerPath){- if (handlerPath != null && pathInfo.TrimStart('/').StartsWith(- handlerPath, StringComparison.OrdinalIgnoreCase))+ var trimmed = pathInfo.TrimStart('/');+ if (handlerPath != null && trimmed.StartsWith(handlerPath, StringComparison.OrdinalIgnoreCase)){- return pathInfo.TrimStart('/').Substring(handlerPath.Length);+ return trimmed.Substring(handlerPath.Length);}return pathInfo;