aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs
diff options
context:
space:
mode:
authorBond-009 <bond.009@outlook.com>2019-09-02 08:19:29 +0200
committerAnthony Lavado <anthonylavado@users.noreply.github.com>2019-09-02 02:19:29 -0400
commitee637e8fecbcefe429babbbbd1325bce7c3fe991 (patch)
treee3d76fb8d753dd43d8d0cff16e199b706ba84980 /Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs
parentcb393c215a2ea75f61d0e3e798c6a4a596d720c2 (diff)
Fix warnings, improve performance (#1665)
* Fix warnings, improve performance `QueryResult.Items` is now a `IReadOnlyList` so we don't need to allocate a new `Array` when we have a `List` (and `Items` shouldn't need to be mutable anyway) * Update Providers .csproj to latest C# * Remove extra newline from DtoService.cs * Remove extra newline from UserLibraryService.cs
Diffstat (limited to 'Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs')
-rw-r--r--Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs17
1 files changed, 12 insertions, 5 deletions
diff --git a/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs b/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs
index 276312a30..457448604 100644
--- a/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs
+++ b/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Net;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.Security;
@@ -89,7 +90,7 @@ namespace Emby.Server.Implementations.HttpServer.Security
AccessToken = token
});
- var tokenInfo = result.Items.Length > 0 ? result.Items[0] : null;
+ var tokenInfo = result.Items.Count > 0 ? result.Items[0] : null;
if (tokenInfo != null)
{
@@ -190,17 +191,23 @@ namespace Emby.Server.Implementations.HttpServer.Security
/// <returns>Dictionary{System.StringSystem.String}.</returns>
private Dictionary<string, string> GetAuthorization(string authorizationHeader)
{
- if (authorizationHeader == null) return null;
+ if (authorizationHeader == null)
+ {
+ return null;
+ }
var parts = authorizationHeader.Split(new[] { ' ' }, 2);
// There should be at least to parts
- if (parts.Length != 2) return null;
+ if (parts.Length != 2)
+ {
+ return null;
+ }
var acceptedNames = new[] { "MediaBrowser", "Emby" };
// It has to be a digest request
- if (!acceptedNames.Contains(parts[0] ?? string.Empty, StringComparer.OrdinalIgnoreCase))
+ if (!acceptedNames.Contains(parts[0], StringComparer.OrdinalIgnoreCase))
{
return null;
}
@@ -232,7 +239,7 @@ namespace Emby.Server.Implementations.HttpServer.Security
return value;
}
- return System.Net.WebUtility.HtmlEncode(value);
+ return WebUtility.HtmlEncode(value);
}
}
}