aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Common')
-rw-r--r--MediaBrowser.Common/Extensions/CollectionExtensions.cs14
-rw-r--r--MediaBrowser.Common/MediaBrowser.Common.csproj3
-rw-r--r--MediaBrowser.Common/Net/HttpRequestOptions.cs9
3 files changed, 21 insertions, 5 deletions
diff --git a/MediaBrowser.Common/Extensions/CollectionExtensions.cs b/MediaBrowser.Common/Extensions/CollectionExtensions.cs
new file mode 100644
index 0000000000..f7c0e3cf04
--- /dev/null
+++ b/MediaBrowser.Common/Extensions/CollectionExtensions.cs
@@ -0,0 +1,14 @@
+using System.Collections.Generic;
+
+namespace MediaBrowser.Common.Extensions
+{
+ // The MS CollectionExtensions are only available in netcoreapp
+ public static class CollectionExtensions
+ {
+ public static TValue GetValueOrDefault<TKey, TValue> (this IReadOnlyDictionary<TKey, TValue> dictionary, TKey key)
+ {
+ dictionary.TryGetValue(key, out var ret);
+ return ret;
+ }
+ }
+}
diff --git a/MediaBrowser.Common/MediaBrowser.Common.csproj b/MediaBrowser.Common/MediaBrowser.Common.csproj
index 715f4fccd3..05b48a2a12 100644
--- a/MediaBrowser.Common/MediaBrowser.Common.csproj
+++ b/MediaBrowser.Common/MediaBrowser.Common.csproj
@@ -1,4 +1,4 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Authors>Jellyfin Contributors</Authors>
@@ -13,6 +13,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.2.0" />
+ <PackageReference Include="Microsoft.Net.Http.Headers" Version="2.2.0" />
</ItemGroup>
<ItemGroup>
diff --git a/MediaBrowser.Common/Net/HttpRequestOptions.cs b/MediaBrowser.Common/Net/HttpRequestOptions.cs
index dadac5e03d..bea178517b 100644
--- a/MediaBrowser.Common/Net/HttpRequestOptions.cs
+++ b/MediaBrowser.Common/Net/HttpRequestOptions.cs
@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
+using Microsoft.Net.Http.Headers;
namespace MediaBrowser.Common.Net
{
@@ -24,8 +25,8 @@ namespace MediaBrowser.Common.Net
/// <value>The accept header.</value>
public string AcceptHeader
{
- get => GetHeaderValue("Accept");
- set => RequestHeaders["Accept"] = value;
+ get => GetHeaderValue(HeaderNames.Accept);
+ set => RequestHeaders[HeaderNames.Accept] = value;
}
/// <summary>
/// Gets or sets the cancellation token.
@@ -45,8 +46,8 @@ namespace MediaBrowser.Common.Net
/// <value>The user agent.</value>
public string UserAgent
{
- get => GetHeaderValue("User-Agent");
- set => RequestHeaders["User-Agent"] = value;
+ get => GetHeaderValue(HeaderNames.UserAgent);
+ set => RequestHeaders[HeaderNames.UserAgent] = value;
}
/// <summary>