mirror of
https://github.com/Radarr/Radarr
synced 2025-02-03 21:32:13 +00:00
DownloadStream will now add a UserAgent to the request.
New: NzbMatrix won't block NzbDrone for not supplying an identifier now.
This commit is contained in:
parent
7d4a3feffa
commit
840fed2408
1 changed files with 14 additions and 1 deletions
|
@ -5,13 +5,25 @@
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using NLog;
|
using NLog;
|
||||||
|
using Ninject;
|
||||||
|
|
||||||
namespace NzbDrone.Common
|
namespace NzbDrone.Common
|
||||||
{
|
{
|
||||||
public class HttpProvider
|
public class HttpProvider
|
||||||
{
|
{
|
||||||
|
private readonly EnvironmentProvider _environmentProvider;
|
||||||
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
|
[Inject]
|
||||||
|
public HttpProvider(EnvironmentProvider environmentProvider)
|
||||||
|
{
|
||||||
|
_environmentProvider = environmentProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HttpProvider()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public virtual string DownloadString(string address)
|
public virtual string DownloadString(string address)
|
||||||
{
|
{
|
||||||
return DownloadString(address, null);
|
return DownloadString(address, null);
|
||||||
|
@ -38,7 +50,8 @@ public virtual string DownloadString(string address, ICredentials identity)
|
||||||
|
|
||||||
public virtual Stream DownloadStream(string url, NetworkCredential credential)
|
public virtual Stream DownloadStream(string url, NetworkCredential credential)
|
||||||
{
|
{
|
||||||
var request = WebRequest.Create(url);
|
var request = (HttpWebRequest)WebRequest.Create(url);
|
||||||
|
request.UserAgent = String.Format("NzbDrone {0}", _environmentProvider.Version);
|
||||||
|
|
||||||
request.Credentials = credential;
|
request.Credentials = credential;
|
||||||
var response = request.GetResponse();
|
var response = request.GetResponse();
|
||||||
|
|
Loading…
Reference in a new issue