aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaus Vium <clausvium@gmail.com>2019-02-26 22:40:25 +0100
committerClaus Vium <clausvium@gmail.com>2019-02-26 22:40:25 +0100
commit9c02e99e35fa6811502944b19dd1479750ff8f20 (patch)
tree18d3cb3e9f61da05c4ec8e4531268632d3048440
parent148db8b81ac4bb52262e071e6920b1449c8611fe (diff)
Undo some of the span abuse
-rw-r--r--Emby.Server.Implementations/ApplicationHost.cs2
-rw-r--r--Emby.Server.Implementations/Emby.Server.Implementations.csproj1
-rw-r--r--Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs25
3 files changed, 9 insertions, 19 deletions
diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs
index a1ea17904..0b4a2fd30 100644
--- a/Emby.Server.Implementations/ApplicationHost.cs
+++ b/Emby.Server.Implementations/ApplicationHost.cs
@@ -1676,7 +1676,7 @@ namespace Emby.Server.Implementations
LogErrorResponseBody = false,
LogErrors = logPing,
LogRequest = logPing,
- TimeoutMs = 30000,
+ TimeoutMs = 5000,
BufferContent = false,
CancellationToken = cancellationToken
diff --git a/Emby.Server.Implementations/Emby.Server.Implementations.csproj b/Emby.Server.Implementations/Emby.Server.Implementations.csproj
index a4dac4a7f..230e4892c 100644
--- a/Emby.Server.Implementations/Emby.Server.Implementations.csproj
+++ b/Emby.Server.Implementations/Emby.Server.Implementations.csproj
@@ -40,6 +40,7 @@
<PackageReference Include="ServiceStack.Text.Core" Version="5.4.0" />
<PackageReference Include="sharpcompress" Version="0.22.0" />
<PackageReference Include="SQLitePCL.pretty.netstandard" Version="1.0.0" />
+ <PackageReference Include="System.Buffers" Version="4.5.0" />
<PackageReference Include="UTF.Unknown" Version="1.0.0-beta1" />
</ItemGroup>
diff --git a/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs b/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs
index 146862e02..35fff0821 100644
--- a/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs
+++ b/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs
@@ -273,11 +273,11 @@ namespace Emby.Server.Implementations.SocketSharp
private static string GetQueryStringContentType(HttpRequest httpReq)
{
- string format = httpReq.Query["format"];
+ ReadOnlySpan<char> format = httpReq.Query["format"].ToString().AsSpan();
if (format == null)
{
const int formatMaxLength = 4;
- string pi = httpReq.Path.ToString();
+ ReadOnlySpan<char> pi = httpReq.Path.ToString().AsSpan();
if (pi == null || pi.Length <= formatMaxLength)
{
return null;
@@ -285,7 +285,7 @@ namespace Emby.Server.Implementations.SocketSharp
if (pi[0] == '/')
{
- pi = pi.Substring(1);
+ pi = pi.Slice(1);
}
format = LeftPart(pi, '/');
@@ -296,11 +296,11 @@ namespace Emby.Server.Implementations.SocketSharp
}
format = LeftPart(format, '.');
- if (format.ToLower().Contains("json"))
+ if (format.Contains("json".AsSpan(), StringComparison.OrdinalIgnoreCase))
{
return "application/json";
}
- else if (format.ToLower().Contains("xml"))
+ else if (format.Contains("xml".AsSpan(), StringComparison.OrdinalIgnoreCase))
{
return "application/xml";
}
@@ -308,25 +308,14 @@ namespace Emby.Server.Implementations.SocketSharp
return null;
}
- public static string LeftPart(string strVal, char needle)
+ public static ReadOnlySpan<char> LeftPart(ReadOnlySpan<char> strVal, char needle)
{
if (strVal == null)
{
return null;
}
- var pos = strVal.IndexOf(needle.ToString(), StringComparison.Ordinal);
- return pos == -1 ? strVal : strVal.Substring(0, pos);
- }
-
- public static ReadOnlySpan<string> LeftPart(ReadOnlySpan<string> strVal, char needle)
- {
- if (strVal == null)
- {
- return null;
- }
-
- var pos = strVal.IndexOf(needle.ToString());
+ var pos = strVal.IndexOf(needle);
return pos == -1 ? strVal : strVal.Slice(0, pos);
}