updated nuget
This commit is contained in:
parent
dbb7fd61ff
commit
26c0b26366
|
@ -1,4 +1,7 @@
|
|||
using System.IO;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
|
||||
namespace MediaBrowser.Model.Dlna
|
||||
{
|
||||
|
@ -16,7 +19,82 @@ namespace MediaBrowser.Model.Dlna
|
|||
|
||||
public virtual bool CanAccessUrl(string url, bool requiresCustomRequestHeaders)
|
||||
{
|
||||
return false;
|
||||
if (requiresCustomRequestHeaders)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return CanAccessUrl(url);
|
||||
}
|
||||
|
||||
private readonly Dictionary<string, TestResult> _results = new Dictionary<string, TestResult>(StringComparer.OrdinalIgnoreCase);
|
||||
private readonly object _resultLock = new object();
|
||||
|
||||
private bool CanAccessUrl(string url)
|
||||
{
|
||||
var key = GetHostFromUrl(url);
|
||||
lock (_resultLock)
|
||||
{
|
||||
TestResult result;
|
||||
if (_results.TryGetValue(url, out result))
|
||||
{
|
||||
var timespan = DateTime.UtcNow - result.Date;
|
||||
if (timespan <= TimeSpan.FromMinutes(3))
|
||||
{
|
||||
return result.Success;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var canAccess = CanAccessUrlInternal(url);
|
||||
lock (_resultLock)
|
||||
{
|
||||
_results[key] = new TestResult
|
||||
{
|
||||
Success = canAccess,
|
||||
Date = DateTime.UtcNow
|
||||
};
|
||||
}
|
||||
return canAccess;
|
||||
}
|
||||
|
||||
private bool CanAccessUrlInternal(string url)
|
||||
{
|
||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
|
||||
request.Timeout = 5000;
|
||||
request.Method = "HEAD";
|
||||
try
|
||||
{
|
||||
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
|
||||
{
|
||||
return response.StatusCode == HttpStatusCode.OK;
|
||||
}
|
||||
}
|
||||
catch (WebException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected void ClearUrlTestResultCache()
|
||||
{
|
||||
lock (_resultLock)
|
||||
{
|
||||
_results.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
private string GetHostFromUrl(string url)
|
||||
{
|
||||
var start = url.IndexOf("://", StringComparison.OrdinalIgnoreCase) + 3;
|
||||
var len = url.IndexOf('/', start) - start;
|
||||
return url.Substring(start, len);
|
||||
}
|
||||
|
||||
private class TestResult
|
||||
{
|
||||
public bool Success;
|
||||
public DateTime Date;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using MediaBrowser.Common.Events;
|
||||
using System.Net.NetworkInformation;
|
||||
using MediaBrowser.Common.Events;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Common.Net;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>MediaBrowser.Common.Internal</id>
|
||||
<version>3.0.587</version>
|
||||
<version>3.0.588</version>
|
||||
<title>MediaBrowser.Common.Internal</title>
|
||||
<authors>Luke</authors>
|
||||
<owners>ebr,Luke,scottisafool</owners>
|
||||
|
@ -12,7 +12,7 @@
|
|||
<description>Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption.</description>
|
||||
<copyright>Copyright © Media Browser 2013</copyright>
|
||||
<dependencies>
|
||||
<dependency id="MediaBrowser.Common" version="3.0.587" />
|
||||
<dependency id="MediaBrowser.Common" version="3.0.588" />
|
||||
<dependency id="NLog" version="3.2.0.0" />
|
||||
<dependency id="SimpleInjector" version="2.7.0" />
|
||||
</dependencies>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>MediaBrowser.Common</id>
|
||||
<version>3.0.587</version>
|
||||
<version>3.0.588</version>
|
||||
<title>MediaBrowser.Common</title>
|
||||
<authors>Media Browser Team</authors>
|
||||
<owners>ebr,Luke,scottisafool</owners>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>MediaBrowser.Model.Signed</id>
|
||||
<version>3.0.587</version>
|
||||
<version>3.0.588</version>
|
||||
<title>MediaBrowser.Model - Signed Edition</title>
|
||||
<authors>Media Browser Team</authors>
|
||||
<owners>ebr,Luke,scottisafool</owners>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>MediaBrowser.Server.Core</id>
|
||||
<version>3.0.587</version>
|
||||
<version>3.0.588</version>
|
||||
<title>Media Browser.Server.Core</title>
|
||||
<authors>Media Browser Team</authors>
|
||||
<owners>ebr,Luke,scottisafool</owners>
|
||||
|
@ -12,7 +12,7 @@
|
|||
<description>Contains core components required to build plugins for Media Browser Server.</description>
|
||||
<copyright>Copyright © Media Browser 2013</copyright>
|
||||
<dependencies>
|
||||
<dependency id="MediaBrowser.Common" version="3.0.587" />
|
||||
<dependency id="MediaBrowser.Common" version="3.0.588" />
|
||||
</dependencies>
|
||||
</metadata>
|
||||
<files>
|
||||
|
|
Loading…
Reference in New Issue
Block a user