aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Server
diff options
context:
space:
mode:
authorJoshua M. Boniface <joshua@boniface.me>2019-01-31 21:11:13 -0500
committerGitHub <noreply@github.com>2019-01-31 21:11:13 -0500
commitc713824bf960b1c0d33dde051da6115f329cbca8 (patch)
tree048d7dfbd47da525cbc5fd7551ea3e27fa643e5e /Jellyfin.Server
parentea851317e76bca0ae4c02547bf7ae017a5a45282 (diff)
parent1ea219bf3f5c0708c3afa5fa2d897ca5212b5e04 (diff)
Merge pull request #734 from Bond-009/culture
Fix more analyzer warnings
Diffstat (limited to 'Jellyfin.Server')
-rw-r--r--Jellyfin.Server/SocketSharp/RequestMono.cs25
-rw-r--r--Jellyfin.Server/SocketSharp/WebSocketSharpRequest.cs41
2 files changed, 43 insertions, 23 deletions
diff --git a/Jellyfin.Server/SocketSharp/RequestMono.cs b/Jellyfin.Server/SocketSharp/RequestMono.cs
index 017690062..f09197fb3 100644
--- a/Jellyfin.Server/SocketSharp/RequestMono.cs
+++ b/Jellyfin.Server/SocketSharp/RequestMono.cs
@@ -360,13 +360,13 @@ namespace Jellyfin.SocketSharp
int len = buffer.Length;
if (dest_offset > len)
{
- throw new ArgumentException("destination offset is beyond array size");
+ throw new ArgumentException("destination offset is beyond array size", nameof(dest_offset));
}
// reordered to avoid possible integer overflow
if (dest_offset > len - count)
{
- throw new ArgumentException("Reading would overrun buffer");
+ throw new ArgumentException("Reading would overrun buffer", nameof(count));
}
if (count > end - position)
@@ -528,7 +528,7 @@ namespace Jellyfin.SocketSharp
}
}
- class HttpMultipart
+ private class HttpMultipart
{
public class Element
@@ -543,19 +543,19 @@ namespace Jellyfin.SocketSharp
public override string ToString()
{
return "ContentType " + ContentType + ", Name " + Name + ", Filename " + Filename + ", Start " +
- Start.ToString() + ", Length " + Length.ToString();
+ Start.ToString(CultureInfo.CurrentCulture) + ", Length " + Length.ToString(CultureInfo.CurrentCulture);
}
}
- Stream data;
- string boundary;
- byte[] boundary_bytes;
- byte[] buffer;
- bool at_eof;
- Encoding encoding;
- StringBuilder sb;
+ private Stream data;
+ private string boundary;
+ private byte[] boundary_bytes;
+ private byte[] buffer;
+ private bool at_eof;
+ private Encoding encoding;
+ private StringBuilder sb;
- const byte LF = (byte)'\n', CR = (byte)'\r';
+ private const byte LF = (byte)'\n', CR = (byte)'\r';
// See RFC 2046
// In the case of multipart entities, in which one or more different
@@ -610,7 +610,6 @@ namespace Jellyfin.SocketSharp
}
return sb.ToString();
-
}
private static string GetContentDispositionAttribute(string l, string name)
diff --git a/Jellyfin.Server/SocketSharp/WebSocketSharpRequest.cs b/Jellyfin.Server/SocketSharp/WebSocketSharpRequest.cs
index 97550e686..2e8dd9185 100644
--- a/Jellyfin.Server/SocketSharp/WebSocketSharpRequest.cs
+++ b/Jellyfin.Server/SocketSharp/WebSocketSharpRequest.cs
@@ -29,12 +29,24 @@ namespace Jellyfin.SocketSharp
private static string GetHandlerPathIfAny(string listenerUrl)
{
- if (listenerUrl == null) return null;
+ if (listenerUrl == null)
+ {
+ return null;
+ }
+
var pos = listenerUrl.IndexOf("://", StringComparison.OrdinalIgnoreCase);
- if (pos == -1) return null;
+ if (pos == -1)
+ {
+ return null;
+ }
+
var startHostUrl = listenerUrl.Substring(pos + "://".Length);
var endPos = startHostUrl.IndexOf('/');
- if (endPos == -1) return null;
+ if (endPos == -1)
+ {
+ return null;
+ }
+
var endHostUrl = startHostUrl.Substring(endPos + 1);
return string.IsNullOrEmpty(endHostUrl) ? null : endHostUrl.TrimEnd('/');
}
@@ -210,9 +222,13 @@ namespace Jellyfin.SocketSharp
if (acceptsAnything)
{
if (hasDefaultContentType)
+ {
return defaultContentType;
- if (serverDefaultContentType != null)
+ }
+ else if (serverDefaultContentType != null)
+ {
return serverDefaultContentType;
+ }
}
}
@@ -229,11 +245,16 @@ namespace Jellyfin.SocketSharp
public static bool HasAnyOfContentTypes(IRequest request, params string[] contentTypes)
{
- if (contentTypes == null || request.ContentType == null) return false;
+ if (contentTypes == null || request.ContentType == null)
+ {
+ return false;
+ }
+
foreach (var contentType in contentTypes)
{
if (IsContentType(request, contentType)) return true;
}
+
return false;
}
@@ -264,12 +285,12 @@ namespace Jellyfin.SocketSharp
}
}
- format = LeftPart(format, '.').ToLower();
+ format = LeftPart(format, '.').ToLowerInvariant();
if (format.Contains("json", StringComparison.OrdinalIgnoreCase))
{
return "application/json";
}
- if (format.Contains("xml", StringComparison.OrdinalIgnoreCase))
+ else if (format.Contains("xml", StringComparison.OrdinalIgnoreCase))
{
return "application/xml";
}
@@ -283,10 +304,9 @@ namespace Jellyfin.SocketSharp
{
return null;
}
+
var pos = strVal.IndexOf(needle);
- return pos == -1
- ? strVal
- : strVal.Substring(0, pos);
+ return pos == -1 ? strVal : strVal.Substring(0, pos);
}
public static string HandlerFactoryPath;
@@ -433,6 +453,7 @@ namespace Jellyfin.SocketSharp
{
return null;
}
+
try
{
return Encoding.GetEncoding(param);