mirror of
https://github.com/Sonarr/Sonarr
synced 2025-01-02 21:24:56 +00:00
9e15b27e3a
Added DownloadString for HttpProvider that allows for authenticaion (required for XBMC with username/password).
43 lines
No EOL
1.2 KiB
C#
43 lines
No EOL
1.2 KiB
C#
using System;
|
|
using System.Net;
|
|
using NLog;
|
|
|
|
namespace NzbDrone.Core.Providers
|
|
{
|
|
internal class HttpProvider : IHttpProvider
|
|
{
|
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
|
|
|
public string DownloadString(string request)
|
|
{
|
|
try
|
|
{
|
|
return new WebClient().DownloadString(request);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Logger.Warn("Failed to get response from: {0}", request);
|
|
Logger.TraceException(ex.Message, ex);
|
|
}
|
|
|
|
return String.Empty;
|
|
}
|
|
|
|
public 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;
|
|
}
|
|
}
|
|
} |