mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
Merge + Download Settings UI Fixes.
This commit is contained in:
@@ -1,80 +1,54 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Xml;
|
||||
using NLog;
|
||||
|
||||
|
||||
namespace NzbDrone.Core.Providers.Core
|
||||
{
|
||||
public class HttpProvider
|
||||
{
|
||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public virtual string DownloadString(string request)
|
||||
public virtual string DownloadString(string address)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new WebClient().DownloadString(request);
|
||||
return new WebClient().DownloadString(address);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Warn("Failed to get response from: {0}", request);
|
||||
Logger.TraceException(ex.Message, ex);
|
||||
}
|
||||
|
||||
return String.Empty;
|
||||
}
|
||||
|
||||
public virtual string DownloadString(string request, string username, string password)
|
||||
{
|
||||
try
|
||||
{
|
||||
var webClient = new WebClient();
|
||||
webClient.Credentials = new NetworkCredential(username, password);
|
||||
return webClient.DownloadString(request);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Warn("Failed to get response from: {0}", request);
|
||||
Logger.TraceException(ex.Message, ex);
|
||||
}
|
||||
|
||||
return String.Empty;
|
||||
}
|
||||
|
||||
public virtual void DownloadFile(string request, string filename)
|
||||
{
|
||||
try
|
||||
{
|
||||
var webClient = new WebClient();
|
||||
webClient.DownloadFile(request, filename);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Warn("Failed to get response from: {0}", request);
|
||||
Logger.Warn("Failed to get response from: {0}", address);
|
||||
Logger.TraceException(ex.Message, ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void DownloadFile(string request, string filename, string username, string password)
|
||||
public virtual string DownloadString(string address, string username, string password)
|
||||
{
|
||||
try
|
||||
{
|
||||
var webClient = new WebClient();
|
||||
webClient.Credentials = new NetworkCredential(username, password);
|
||||
webClient.DownloadFile(request, filename);
|
||||
return webClient.DownloadString(address);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Warn("Failed to get response from: {0}", request);
|
||||
Logger.Warn("Failed to get response from: {0}", address);
|
||||
Logger.TraceException(ex.Message, ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual XmlReader DownloadXml(string url)
|
||||
public virtual Stream DownloadStream(string url)
|
||||
{
|
||||
return XmlReader.Create(url);
|
||||
var request = WebRequest.Create(url);
|
||||
|
||||
var response = request.GetResponse();
|
||||
|
||||
return response.GetResponseStream();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user