Fix more warnings

This commit is contained in:
Bond-009 2019-02-08 00:07:57 +01:00
parent f60ad53393
commit 38d9eeffbe
2 changed files with 39 additions and 37 deletions

View File

@ -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.SocketSharp
return 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)
@ -130,7 +130,7 @@ namespace Jellyfin.SocketSharp
protected 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.SocketSharp
throw 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.SocketSharp
validate_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.SocketSharp
return 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.SocketSharp
value.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.SocketSharp
public 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.SocketSharp
real = position + d;
break;
default:
throw new ArgumentException();
throw new ArgumentException(nameof(origin));
}
long virt = real - offset;
@ -491,7 +491,7 @@ namespace Jellyfin.SocketSharp
public Stream InputStream => stream;
}
class Helpers
private class Helpers
{
public static readonly CultureInfo InvariantCulture = CultureInfo.InvariantCulture;
}
@ -614,7 +614,7 @@ namespace Jellyfin.SocketSharp
private 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.SocketSharp
private 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] != '-')
{

View File

@ -80,8 +80,8 @@ namespace Jellyfin.SocketSharp
private 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.SocketSharp
return 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.SocketSharp
return 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.SocketSharp
public 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;