mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 13:57:14 -04:00
Undo some of the span abuse
This commit is contained in:
parent
148db8b81a
commit
9c02e99e35
@ -1676,7 +1676,7 @@ namespace Emby.Server.Implementations
|
|||||||
LogErrorResponseBody = false,
|
LogErrorResponseBody = false,
|
||||||
LogErrors = logPing,
|
LogErrors = logPing,
|
||||||
LogRequest = logPing,
|
LogRequest = logPing,
|
||||||
TimeoutMs = 30000,
|
TimeoutMs = 5000,
|
||||||
BufferContent = false,
|
BufferContent = false,
|
||||||
|
|
||||||
CancellationToken = cancellationToken
|
CancellationToken = cancellationToken
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
<PackageReference Include="ServiceStack.Text.Core" Version="5.4.0" />
|
<PackageReference Include="ServiceStack.Text.Core" Version="5.4.0" />
|
||||||
<PackageReference Include="sharpcompress" Version="0.22.0" />
|
<PackageReference Include="sharpcompress" Version="0.22.0" />
|
||||||
<PackageReference Include="SQLitePCL.pretty.netstandard" Version="1.0.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" />
|
<PackageReference Include="UTF.Unknown" Version="1.0.0-beta1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@ -273,11 +273,11 @@ namespace Emby.Server.Implementations.SocketSharp
|
|||||||
|
|
||||||
private static string GetQueryStringContentType(HttpRequest httpReq)
|
private static string GetQueryStringContentType(HttpRequest httpReq)
|
||||||
{
|
{
|
||||||
string format = httpReq.Query["format"];
|
ReadOnlySpan<char> format = httpReq.Query["format"].ToString().AsSpan();
|
||||||
if (format == null)
|
if (format == null)
|
||||||
{
|
{
|
||||||
const int formatMaxLength = 4;
|
const int formatMaxLength = 4;
|
||||||
string pi = httpReq.Path.ToString();
|
ReadOnlySpan<char> pi = httpReq.Path.ToString().AsSpan();
|
||||||
if (pi == null || pi.Length <= formatMaxLength)
|
if (pi == null || pi.Length <= formatMaxLength)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
@ -285,7 +285,7 @@ namespace Emby.Server.Implementations.SocketSharp
|
|||||||
|
|
||||||
if (pi[0] == '/')
|
if (pi[0] == '/')
|
||||||
{
|
{
|
||||||
pi = pi.Substring(1);
|
pi = pi.Slice(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
format = LeftPart(pi, '/');
|
format = LeftPart(pi, '/');
|
||||||
@ -296,11 +296,11 @@ namespace Emby.Server.Implementations.SocketSharp
|
|||||||
}
|
}
|
||||||
|
|
||||||
format = LeftPart(format, '.');
|
format = LeftPart(format, '.');
|
||||||
if (format.ToLower().Contains("json"))
|
if (format.Contains("json".AsSpan(), StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
return "application/json";
|
return "application/json";
|
||||||
}
|
}
|
||||||
else if (format.ToLower().Contains("xml"))
|
else if (format.Contains("xml".AsSpan(), StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
return "application/xml";
|
return "application/xml";
|
||||||
}
|
}
|
||||||
@ -308,25 +308,14 @@ namespace Emby.Server.Implementations.SocketSharp
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string LeftPart(string strVal, char needle)
|
public static ReadOnlySpan<char> LeftPart(ReadOnlySpan<char> strVal, char needle)
|
||||||
{
|
{
|
||||||
if (strVal == null)
|
if (strVal == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var pos = strVal.IndexOf(needle.ToString(), StringComparison.Ordinal);
|
var pos = strVal.IndexOf(needle);
|
||||||
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());
|
|
||||||
return pos == -1 ? strVal : strVal.Slice(0, pos);
|
return pos == -1 ? strVal : strVal.Slice(0, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user