From e2633318801586dd509e91154a8a8a72392f25e6 Mon Sep 17 00:00:00 2001 From: Qstick Date: Wed, 28 Jul 2021 23:15:10 -0400 Subject: [PATCH] Fixed: Remove obsolete HttpProvider Co-Authored-By: ta264 --- src/NzbDrone.Common.Test/WebClientTests.cs | 31 --------- src/NzbDrone.Common/Http/HttpProvider.cs | 63 ------------------- src/NzbDrone.Core.Test/Framework/CoreTest.cs | 1 - .../ImportDecisionMakerFixture.cs | 1 - 4 files changed, 96 deletions(-) delete mode 100644 src/NzbDrone.Common.Test/WebClientTests.cs delete mode 100644 src/NzbDrone.Common/Http/HttpProvider.cs diff --git a/src/NzbDrone.Common.Test/WebClientTests.cs b/src/NzbDrone.Common.Test/WebClientTests.cs deleted file mode 100644 index 46a3561c8..000000000 --- a/src/NzbDrone.Common.Test/WebClientTests.cs +++ /dev/null @@ -1,31 +0,0 @@ - -using System; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Common.Http; -using NzbDrone.Test.Common; - -namespace NzbDrone.Common.Test -{ - [TestFixture] - public class WebClientTests : TestBase - { - [Test] - public void DownloadString_should_be_able_to_dowload_text_file() - { - var jquery = Subject.DownloadString("http://www.google.com/robots.txt"); - - jquery.Should().NotBeNullOrWhiteSpace(); - jquery.Should().Contain("Sitemap"); - } - - [TestCase("")] - [TestCase("http://")] - public void DownloadString_should_throw_on_error(string url) - { - Action action = () => Subject.DownloadString(url); - action.Should().Throw(); - ExceptionVerification.ExpectedWarns(1); - } - } -} diff --git a/src/NzbDrone.Common/Http/HttpProvider.cs b/src/NzbDrone.Common/Http/HttpProvider.cs deleted file mode 100644 index a61ac8a14..000000000 --- a/src/NzbDrone.Common/Http/HttpProvider.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using System.Net; -using NLog; -using NzbDrone.Common.EnvironmentInfo; - -namespace NzbDrone.Common.Http -{ - [Obsolete("Use IHttpClient")] - public interface IHttpProvider - { - string DownloadString(string url); - string DownloadString(string url, string username, string password); - } - - - [Obsolete("Use HttpProvider")] - public class HttpProvider : IHttpProvider - { - private readonly Logger _logger; - - - private readonly string _userAgent; - - public HttpProvider(Logger logger) - { - _logger = logger; - _userAgent = $"{BuildInfo.AppName}/{BuildInfo.Version.ToString(2)}"; - ServicePointManager.Expect100Continue = false; - } - - public string DownloadString(string url) - { - return DownloadString(url, null); - } - - public string DownloadString(string url, string username, string password) - { - return DownloadString(url, new NetworkCredential(username, password)); - } - - private string DownloadString(string url, ICredentials identity) - { - try - { - var client = new GZipWebClient { Credentials = identity }; - client.Headers.Add(HttpRequestHeader.UserAgent, _userAgent); - return client.DownloadString(url); - } - catch (WebException e) - { - _logger.Warn("Failed to get response from: {0} {1}", url, e.Message); - throw; - } - catch (Exception e) - { - _logger.Warn(e, "Failed to get response from: " + url); - throw; - } - } - - - } -} \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/Framework/CoreTest.cs b/src/NzbDrone.Core.Test/Framework/CoreTest.cs index edf574f88..ba4f3a03c 100644 --- a/src/NzbDrone.Core.Test/Framework/CoreTest.cs +++ b/src/NzbDrone.Core.Test/Framework/CoreTest.cs @@ -24,7 +24,6 @@ namespace NzbDrone.Core.Test.Framework Mocker.SetConstant(new HttpProxySettingsProvider(Mocker.Resolve())); Mocker.SetConstant(new ManagedWebProxyFactory(Mocker.Resolve())); Mocker.SetConstant(new ManagedHttpDispatcher(Mocker.Resolve(), Mocker.Resolve(), Mocker.Resolve(), Mocker.Resolve(), TestLogger)); - Mocker.SetConstant(new HttpProvider(TestLogger)); Mocker.SetConstant(new HttpClient(new IHttpRequestInterceptor[0], Mocker.Resolve(), Mocker.Resolve(), Mocker.Resolve(), Mocker.Resolve(), TestLogger)); Mocker.SetConstant(new SonarrCloudRequestBuilder()); } diff --git a/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/ImportDecisionMakerFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/ImportDecisionMakerFixture.cs index 21feb0a09..cf1cceee1 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/ImportDecisionMakerFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/EpisodeImport/ImportDecisionMakerFixture.cs @@ -25,7 +25,6 @@ namespace NzbDrone.Core.Test.MediaFiles.EpisodeImport { private List _videoFiles; private LocalEpisode _localEpisode; - private DownloadClientItem _downloadClientItem; private Series _series; private QualityModel _quality;