diff --git a/src/NzbDrone.Common/Http/HttpClient.cs b/src/NzbDrone.Common/Http/HttpClient.cs index 47286b3b0..9c1e2221c 100644 --- a/src/NzbDrone.Common/Http/HttpClient.cs +++ b/src/NzbDrone.Common/Http/HttpClient.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Net; +using System.Net.Http; using System.Threading.Tasks; using NLog; using NzbDrone.Common.Cache; @@ -87,7 +88,7 @@ namespace NzbDrone.Common.Http // 302 or 303 should default to GET on redirect even if POST on original if (response.StatusCode == HttpStatusCode.Redirect || response.StatusCode == HttpStatusCode.RedirectMethod) { - request.Method = HttpMethod.GET; + request.Method = HttpMethod.Get; request.ContentData = null; } @@ -263,7 +264,7 @@ namespace NzbDrone.Common.Http public Task GetAsync(HttpRequest request) { - request.Method = HttpMethod.GET; + request.Method = HttpMethod.Get; return ExecuteAsync(request); } @@ -288,7 +289,7 @@ namespace NzbDrone.Common.Http public Task HeadAsync(HttpRequest request) { - request.Method = HttpMethod.HEAD; + request.Method = HttpMethod.Head; return ExecuteAsync(request); } @@ -299,7 +300,7 @@ namespace NzbDrone.Common.Http public Task PostAsync(HttpRequest request) { - request.Method = HttpMethod.POST; + request.Method = HttpMethod.Post; return ExecuteAsync(request); } diff --git a/src/NzbDrone.Common/Http/HttpMethod.cs b/src/NzbDrone.Common/Http/HttpMethod.cs deleted file mode 100644 index 8964bbef6..000000000 --- a/src/NzbDrone.Common/Http/HttpMethod.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace NzbDrone.Common.Http -{ - public enum HttpMethod - { - GET, - POST, - PUT, - DELETE, - HEAD, - OPTIONS, - PATCH, - MERGE - } -} diff --git a/src/NzbDrone.Common/Http/HttpRequest.cs b/src/NzbDrone.Common/Http/HttpRequest.cs index 9f2aab320..769712386 100644 --- a/src/NzbDrone.Common/Http/HttpRequest.cs +++ b/src/NzbDrone.Common/Http/HttpRequest.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Net; +using System.Net.Http; using System.Text; using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Common.Extensions; diff --git a/src/NzbDrone.Common/Http/HttpRequestBuilder.cs b/src/NzbDrone.Common/Http/HttpRequestBuilder.cs index 644d73908..86b40b319 100644 --- a/src/NzbDrone.Common/Http/HttpRequestBuilder.cs +++ b/src/NzbDrone.Common/Http/HttpRequestBuilder.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Net; +using System.Net.Http; using System.Text; using NzbDrone.Common.Extensions; @@ -37,7 +38,7 @@ namespace NzbDrone.Common.Http { BaseUrl = new HttpUri(baseUrl); ResourceUrl = string.Empty; - Method = HttpMethod.GET; + Method = HttpMethod.Get; Encoding = Encoding.UTF8; QueryParams = new List>(); SuffixQueryParams = new List>(); @@ -275,7 +276,7 @@ namespace NzbDrone.Common.Http public virtual HttpRequestBuilder Post() { - Method = HttpMethod.POST; + Method = HttpMethod.Post; return this; } @@ -397,7 +398,7 @@ namespace NzbDrone.Common.Http public virtual HttpRequestBuilder AddFormParameter(string key, object value) { - if (Method != HttpMethod.POST) + if (Method != HttpMethod.Post) { throw new NotSupportedException("HttpRequest Method must be POST to add FormParameter."); } @@ -413,7 +414,7 @@ namespace NzbDrone.Common.Http public virtual HttpRequestBuilder AddFormUpload(string name, string fileName, byte[] data, string contentType = "application/octet-stream") { - if (Method != HttpMethod.POST) + if (Method != HttpMethod.Post) { throw new NotSupportedException("HttpRequest Method must be POST to add FormUpload."); } diff --git a/src/NzbDrone.Common/Http/JsonRpcRequestBuilder.cs b/src/NzbDrone.Common/Http/JsonRpcRequestBuilder.cs index ae987a23d..06b113e54 100644 --- a/src/NzbDrone.Common/Http/JsonRpcRequestBuilder.cs +++ b/src/NzbDrone.Common/Http/JsonRpcRequestBuilder.cs @@ -1,6 +1,7 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; +using System.Net.Http; using Newtonsoft.Json; using NzbDrone.Common.Serializer; @@ -17,14 +18,14 @@ namespace NzbDrone.Common.Http public JsonRpcRequestBuilder(string baseUrl) : base(baseUrl) { - Method = HttpMethod.POST; + Method = HttpMethod.Post; JsonParameters = new List(); } public JsonRpcRequestBuilder(string baseUrl, string method, IEnumerable parameters) : base(baseUrl) { - Method = HttpMethod.POST; + Method = HttpMethod.Post; JsonMethod = method; JsonParameters = parameters.ToList(); } diff --git a/src/NzbDrone.Core.Test/IndexerTests/AvistazTests/AvistazFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/AvistazTests/AvistazFixture.cs index 50443ac8f..230512265 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/AvistazTests/AvistazFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/AvistazTests/AvistazFixture.cs @@ -1,6 +1,7 @@ using System; using System.Linq; using System.Net; +using System.Net.Http; using System.Threading.Tasks; using FluentAssertions; using Moq; @@ -34,7 +35,7 @@ namespace NzbDrone.Core.Test.IndexerTests.AvistazTests var recentFeed = ReadAllText(@"Files/Indexers/Avistaz/recentfeed.json"); Mocker.GetMock() - .Setup(o => o.ExecuteProxiedAsync(It.Is(v => v.Method == HttpMethod.GET), Subject.Definition)) + .Setup(o => o.ExecuteProxiedAsync(It.Is(v => v.Method == HttpMethod.Get), Subject.Definition)) .Returns((r, d) => Task.FromResult(new HttpResponse(r, new HttpHeader { { "Content-Type", "application/json" } }, new CookieCollection(), recentFeed))); var releases = (await Subject.Fetch(new MovieSearchCriteria { Categories = new int[] { 2000 } })).Releases; diff --git a/src/NzbDrone.Core.Test/IndexerTests/AvistazTests/PrivateHDFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/AvistazTests/PrivateHDFixture.cs index 377fdd968..e259a928c 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/AvistazTests/PrivateHDFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/AvistazTests/PrivateHDFixture.cs @@ -1,6 +1,7 @@ using System; using System.Linq; using System.Net; +using System.Net.Http; using System.Threading.Tasks; using FluentAssertions; using Moq; @@ -34,7 +35,7 @@ namespace NzbDrone.Core.Test.IndexerTests.AvistazTests var recentFeed = ReadAllText(@"Files/Indexers/PrivateHD/recentfeed.json"); Mocker.GetMock() - .Setup(o => o.ExecuteProxiedAsync(It.Is(v => v.Method == HttpMethod.GET), Subject.Definition)) + .Setup(o => o.ExecuteProxiedAsync(It.Is(v => v.Method == HttpMethod.Get), Subject.Definition)) .Returns((r, d) => Task.FromResult(new HttpResponse(r, new HttpHeader { { "Content-Type", "application/json" } }, new CookieCollection(), recentFeed))); var releases = (await Subject.Fetch(new MovieSearchCriteria { Categories = new int[] { 2000 } })).Releases; diff --git a/src/NzbDrone.Core.Test/IndexerTests/FileListTests/FileListFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/FileListTests/FileListFixture.cs index 12f12c095..55a9c47b6 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/FileListTests/FileListFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/FileListTests/FileListFixture.cs @@ -1,6 +1,7 @@ using System; using System.Linq; using System.Net; +using System.Net.Http; using System.Threading.Tasks; using FluentAssertions; using Moq; @@ -33,7 +34,7 @@ namespace NzbDrone.Core.Test.IndexerTests.FileListTests var recentFeed = ReadAllText(@"Files/Indexers/FileList/recentfeed.json"); Mocker.GetMock() - .Setup(o => o.ExecuteProxiedAsync(It.Is(v => v.Method == HttpMethod.GET), Subject.Definition)) + .Setup(o => o.ExecuteProxiedAsync(It.Is(v => v.Method == HttpMethod.Get), Subject.Definition)) .Returns((r, d) => Task.FromResult(new HttpResponse(r, new HttpHeader(), new CookieCollection(), recentFeed))); var releases = (await Subject.Fetch(new MovieSearchCriteria { Categories = new int[] { 2000 } })).Releases; diff --git a/src/NzbDrone.Core.Test/IndexerTests/HDBitsTests/HDBitsFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/HDBitsTests/HDBitsFixture.cs index 91e3efcf0..2592d6874 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/HDBitsTests/HDBitsFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/HDBitsTests/HDBitsFixture.cs @@ -1,6 +1,7 @@ using System; using System.Linq; using System.Net; +using System.Net.Http; using System.Text; using System.Threading.Tasks; using FluentAssertions; @@ -45,7 +46,7 @@ namespace NzbDrone.Core.Test.IndexerTests.HDBitsTests var responseJson = ReadAllText(fileName); Mocker.GetMock() - .Setup(o => o.ExecuteProxiedAsync(It.Is(v => v.Method == HttpMethod.POST), Subject.Definition)) + .Setup(o => o.ExecuteProxiedAsync(It.Is(v => v.Method == HttpMethod.Post), Subject.Definition)) .Returns((r, d) => Task.FromResult(new HttpResponse(r, new HttpHeader(), new CookieCollection(), responseJson))); var torrents = (await Subject.Fetch(_movieSearchCriteria)).Releases; diff --git a/src/NzbDrone.Core.Test/IndexerTests/NewznabTests/NewznabFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/NewznabTests/NewznabFixture.cs index 75ba1038c..231c4bb56 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/NewznabTests/NewznabFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/NewznabTests/NewznabFixture.cs @@ -1,6 +1,7 @@ using System; using System.Linq; using System.Net; +using System.Net.Http; using System.Threading.Tasks; using FluentAssertions; using Moq; @@ -43,7 +44,7 @@ namespace NzbDrone.Core.Test.IndexerTests.NewznabTests var recentFeed = ReadAllText(@"Files/Indexers/Newznab/newznab_nzb_su.xml"); Mocker.GetMock() - .Setup(o => o.ExecuteProxiedAsync(It.Is(v => v.Method == HttpMethod.GET), Subject.Definition)) + .Setup(o => o.ExecuteProxiedAsync(It.Is(v => v.Method == HttpMethod.Get), Subject.Definition)) .Returns((r, d) => Task.FromResult(new HttpResponse(r, new HttpHeader(), new CookieCollection(), recentFeed))); var releases = (await Subject.Fetch(new MovieSearchCriteria { Categories = new int[] { 2000 }, Limit = 100, Offset = 0 })).Releases; diff --git a/src/NzbDrone.Core.Test/IndexerTests/PTPTests/PTPFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/PTPTests/PTPFixture.cs index b9827e838..2f606c420 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/PTPTests/PTPFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/PTPTests/PTPFixture.cs @@ -1,5 +1,6 @@ using System.Linq; using System.Net; +using System.Net.Http; using System.Threading.Tasks; using FluentAssertions; using Moq; @@ -37,11 +38,11 @@ namespace NzbDrone.Core.Test.IndexerTests.PTPTests var responseJson = ReadAllText(fileName); Mocker.GetMock() - .Setup(o => o.ExecuteProxiedAsync(It.Is(v => v.Method == HttpMethod.POST), Subject.Definition)) + .Setup(o => o.ExecuteProxiedAsync(It.Is(v => v.Method == HttpMethod.Post), Subject.Definition)) .Returns((r, d) => Task.FromResult(new HttpResponse(r, new HttpHeader(), new CookieCollection(), authStream.ToString()))); Mocker.GetMock() - .Setup(o => o.ExecuteProxiedAsync(It.Is(v => v.Method == HttpMethod.GET), Subject.Definition)) + .Setup(o => o.ExecuteProxiedAsync(It.Is(v => v.Method == HttpMethod.Get), Subject.Definition)) .Returns((r, d) => Task.FromResult(new HttpResponse(r, new HttpHeader { ContentType = HttpAccept.Json.Value }, new CookieCollection(), responseJson))); var torrents = (await Subject.Fetch(new MovieSearchCriteria())).Releases; diff --git a/src/NzbDrone.Core.Test/IndexerTests/RarbgTests/RarbgFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/RarbgTests/RarbgFixture.cs index c9649ee52..e8da2e1b3 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/RarbgTests/RarbgFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/RarbgTests/RarbgFixture.cs @@ -1,6 +1,7 @@ using System; using System.Linq; using System.Net; +using System.Net.Http; using System.Threading.Tasks; using FluentAssertions; using Moq; @@ -39,7 +40,7 @@ namespace NzbDrone.Core.Test.IndexerTests.RarbgTests var recentFeed = ReadAllText(@"Files/Indexers/Rarbg/RecentFeed_v2.json"); Mocker.GetMock() - .Setup(o => o.ExecuteProxiedAsync(It.Is(v => v.Method == HttpMethod.GET), Subject.Definition)) + .Setup(o => o.ExecuteProxiedAsync(It.Is(v => v.Method == HttpMethod.Get), Subject.Definition)) .Returns((r, d) => Task.FromResult(new HttpResponse(r, new HttpHeader(), new CookieCollection(), recentFeed))); var releases = (await Subject.Fetch(new MovieSearchCriteria { Categories = new int[] { 2000 } })).Releases; @@ -66,7 +67,7 @@ namespace NzbDrone.Core.Test.IndexerTests.RarbgTests public async Task should_parse_error_20_as_empty_results() { Mocker.GetMock() - .Setup(o => o.ExecuteProxiedAsync(It.Is(v => v.Method == HttpMethod.GET), Subject.Definition)) + .Setup(o => o.ExecuteProxiedAsync(It.Is(v => v.Method == HttpMethod.Get), Subject.Definition)) .Returns((r, d) => Task.FromResult(new HttpResponse(r, new HttpHeader(), new CookieCollection(), "{ error_code: 20, error: \"some message\" }"))); var releases = (await Subject.Fetch(new MovieSearchCriteria { Categories = new int[] { 2000 } })).Releases; @@ -78,7 +79,7 @@ namespace NzbDrone.Core.Test.IndexerTests.RarbgTests public async Task should_warn_on_unknown_error() { Mocker.GetMock() - .Setup(o => o.ExecuteProxiedAsync(It.Is(v => v.Method == HttpMethod.GET), Subject.Definition)) + .Setup(o => o.ExecuteProxiedAsync(It.Is(v => v.Method == HttpMethod.Get), Subject.Definition)) .Returns((r, d) => Task.FromResult(new HttpResponse(r, new HttpHeader(), new CookieCollection(), "{ error_code: 25, error: \"some message\" }"))); var releases = (await Subject.Fetch(new MovieSearchCriteria { Categories = new int[] { 2000 } })).Releases; diff --git a/src/NzbDrone.Core.Test/IndexerTests/TorznabTests/TorznabFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/TorznabTests/TorznabFixture.cs index 588a41349..2c96236fc 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/TorznabTests/TorznabFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/TorznabTests/TorznabFixture.cs @@ -1,6 +1,7 @@ using System; using System.Linq; using System.Net; +using System.Net.Http; using System.Threading.Tasks; using FluentAssertions; using Moq; @@ -44,7 +45,7 @@ namespace NzbDrone.Core.Test.IndexerTests.TorznabTests var recentFeed = ReadAllText(@"Files/Indexers/Torznab/torznab_hdaccess_net.xml"); Mocker.GetMock() - .Setup(o => o.ExecuteProxiedAsync(It.Is(v => v.Method == HttpMethod.GET), Subject.Definition)) + .Setup(o => o.ExecuteProxiedAsync(It.Is(v => v.Method == HttpMethod.Get), Subject.Definition)) .Returns((r, d) => Task.FromResult(new HttpResponse(r, new HttpHeader(), new CookieCollection(), recentFeed))); var releases = (await Subject.Fetch(new MovieSearchCriteria())).Releases; @@ -73,7 +74,7 @@ namespace NzbDrone.Core.Test.IndexerTests.TorznabTests var recentFeed = ReadAllText(@"Files/Indexers/Torznab/torznab_tpb.xml"); Mocker.GetMock() - .Setup(o => o.ExecuteProxiedAsync(It.Is(v => v.Method == HttpMethod.GET), Subject.Definition)) + .Setup(o => o.ExecuteProxiedAsync(It.Is(v => v.Method == HttpMethod.Get), Subject.Definition)) .Returns((r, d) => Task.FromResult(new HttpResponse(r, new HttpHeader(), new CookieCollection(), recentFeed))); var releases = (await Subject.Fetch(new MovieSearchCriteria())).Releases; @@ -103,7 +104,7 @@ namespace NzbDrone.Core.Test.IndexerTests.TorznabTests var recentFeed = ReadAllText(@"Files/Indexers/Torznab/torznab_animetosho.xml"); Mocker.GetMock() - .Setup(o => o.ExecuteProxiedAsync(It.Is(v => v.Method == HttpMethod.GET), Subject.Definition)) + .Setup(o => o.ExecuteProxiedAsync(It.Is(v => v.Method == HttpMethod.Get), Subject.Definition)) .Returns((r, d) => Task.FromResult(new HttpResponse(r, new HttpHeader(), new CookieCollection(), recentFeed))); var releases = (await Subject.Fetch(new MovieSearchCriteria())).Releases; diff --git a/src/NzbDrone.Core/Applications/LazyLibrarian/LazyLibrarianV1Proxy.cs b/src/NzbDrone.Core/Applications/LazyLibrarian/LazyLibrarianV1Proxy.cs index abb1c0338..dbf435f65 100644 --- a/src/NzbDrone.Core/Applications/LazyLibrarian/LazyLibrarianV1Proxy.cs +++ b/src/NzbDrone.Core/Applications/LazyLibrarian/LazyLibrarianV1Proxy.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Net.Http; using FluentValidation.Results; using Newtonsoft.Json; using NLog; @@ -31,13 +32,13 @@ namespace NzbDrone.Core.Applications.LazyLibrarian public LazyLibrarianStatus GetStatus(LazyLibrarianSettings settings) { - var request = BuildRequest(settings, "/api", "getVersion", HttpMethod.GET); + var request = BuildRequest(settings, "/api", "getVersion", HttpMethod.Get); return Execute(request); } public List GetIndexers(LazyLibrarianSettings settings) { - var request = BuildRequest(settings, "/api", "listNabProviders", HttpMethod.GET); + var request = BuildRequest(settings, "/api", "listNabProviders", HttpMethod.Get); var response = Execute(request); @@ -76,7 +77,7 @@ namespace NzbDrone.Core.Applications.LazyLibrarian { "providertype", indexerType.ToString().ToLower() } }; - var request = BuildRequest(settings, "/api", "delProvider", HttpMethod.GET, parameters); + var request = BuildRequest(settings, "/api", "delProvider", HttpMethod.Get, parameters); CheckForError(Execute(request)); } @@ -92,7 +93,7 @@ namespace NzbDrone.Core.Applications.LazyLibrarian { "categories", indexer.Categories } }; - var request = BuildRequest(settings, "/api", "addProvider", HttpMethod.GET, parameters); + var request = BuildRequest(settings, "/api", "addProvider", HttpMethod.Get, parameters); CheckForError(Execute(request)); return indexer; } @@ -110,7 +111,7 @@ namespace NzbDrone.Core.Applications.LazyLibrarian { "altername", indexer.Altername } }; - var request = BuildRequest(settings, "/api", "changeProvider", HttpMethod.GET, parameters); + var request = BuildRequest(settings, "/api", "changeProvider", HttpMethod.Get, parameters); CheckForError(Execute(request)); return indexer; } diff --git a/src/NzbDrone.Core/Applications/Lidarr/LidarrV1Proxy.cs b/src/NzbDrone.Core/Applications/Lidarr/LidarrV1Proxy.cs index 6eff2a1a6..449ce6236 100644 --- a/src/NzbDrone.Core/Applications/Lidarr/LidarrV1Proxy.cs +++ b/src/NzbDrone.Core/Applications/Lidarr/LidarrV1Proxy.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Net; +using System.Net.Http; using FluentValidation.Results; using Newtonsoft.Json; using NLog; @@ -33,13 +34,13 @@ namespace NzbDrone.Core.Applications.Lidarr public LidarrStatus GetStatus(LidarrSettings settings) { - var request = BuildRequest(settings, "/api/v1/system/status", HttpMethod.GET); + var request = BuildRequest(settings, "/api/v1/system/status", HttpMethod.Get); return Execute(request); } public List GetIndexers(LidarrSettings settings) { - var request = BuildRequest(settings, "/api/v1/indexer", HttpMethod.GET); + var request = BuildRequest(settings, "/api/v1/indexer", HttpMethod.Get); return Execute>(request); } @@ -47,7 +48,7 @@ namespace NzbDrone.Core.Applications.Lidarr { try { - var request = BuildRequest(settings, $"/api/v1/indexer/{indexerId}", HttpMethod.GET); + var request = BuildRequest(settings, $"/api/v1/indexer/{indexerId}", HttpMethod.Get); return Execute(request); } catch (HttpException ex) @@ -63,19 +64,19 @@ namespace NzbDrone.Core.Applications.Lidarr public void RemoveIndexer(int indexerId, LidarrSettings settings) { - var request = BuildRequest(settings, $"/api/v1/indexer/{indexerId}", HttpMethod.DELETE); + var request = BuildRequest(settings, $"/api/v1/indexer/{indexerId}", HttpMethod.Delete); _httpClient.Execute(request); } public List GetIndexerSchema(LidarrSettings settings) { - var request = BuildRequest(settings, "/api/v1/indexer/schema", HttpMethod.GET); + var request = BuildRequest(settings, "/api/v1/indexer/schema", HttpMethod.Get); return Execute>(request); } public LidarrIndexer AddIndexer(LidarrIndexer indexer, LidarrSettings settings) { - var request = BuildRequest(settings, "/api/v1/indexer", HttpMethod.POST); + var request = BuildRequest(settings, "/api/v1/indexer", HttpMethod.Post); request.SetContent(indexer.ToJson()); @@ -84,7 +85,7 @@ namespace NzbDrone.Core.Applications.Lidarr public LidarrIndexer UpdateIndexer(LidarrIndexer indexer, LidarrSettings settings) { - var request = BuildRequest(settings, $"/api/v1/indexer/{indexer.Id}", HttpMethod.PUT); + var request = BuildRequest(settings, $"/api/v1/indexer/{indexer.Id}", HttpMethod.Put); request.SetContent(indexer.ToJson()); @@ -93,7 +94,7 @@ namespace NzbDrone.Core.Applications.Lidarr public ValidationFailure TestConnection(LidarrIndexer indexer, LidarrSettings settings) { - var request = BuildRequest(settings, $"/api/v1/indexer/test", HttpMethod.POST); + var request = BuildRequest(settings, $"/api/v1/indexer/test", HttpMethod.Post); request.SetContent(indexer.ToJson()); diff --git a/src/NzbDrone.Core/Applications/Mylar/MylarV3Proxy.cs b/src/NzbDrone.Core/Applications/Mylar/MylarV3Proxy.cs index c571d189b..4c72160e9 100644 --- a/src/NzbDrone.Core/Applications/Mylar/MylarV3Proxy.cs +++ b/src/NzbDrone.Core/Applications/Mylar/MylarV3Proxy.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Net.Http; using FluentValidation.Results; using Newtonsoft.Json; using NLog; @@ -31,13 +32,13 @@ namespace NzbDrone.Core.Applications.Mylar public MylarStatus GetStatus(MylarSettings settings) { - var request = BuildRequest(settings, "/api", "getVersion", HttpMethod.GET); + var request = BuildRequest(settings, "/api", "getVersion", HttpMethod.Get); return Execute(request); } public List GetIndexers(MylarSettings settings) { - var request = BuildRequest(settings, "/api", "listProviders", HttpMethod.GET); + var request = BuildRequest(settings, "/api", "listProviders", HttpMethod.Get); var response = Execute(request); @@ -76,7 +77,7 @@ namespace NzbDrone.Core.Applications.Mylar { "providertype", indexerType.ToString().ToLower() } }; - var request = BuildRequest(settings, "/api", "delProvider", HttpMethod.GET, parameters); + var request = BuildRequest(settings, "/api", "delProvider", HttpMethod.Get, parameters); CheckForError(Execute(request)); } @@ -92,7 +93,7 @@ namespace NzbDrone.Core.Applications.Mylar { "categories", indexer.Categories } }; - var request = BuildRequest(settings, "/api", "addProvider", HttpMethod.GET, parameters); + var request = BuildRequest(settings, "/api", "addProvider", HttpMethod.Get, parameters); CheckForError(Execute(request)); return indexer; } @@ -110,7 +111,7 @@ namespace NzbDrone.Core.Applications.Mylar { "altername", indexer.Altername } }; - var request = BuildRequest(settings, "/api", "changeProvider", HttpMethod.GET, parameters); + var request = BuildRequest(settings, "/api", "changeProvider", HttpMethod.Get, parameters); CheckForError(Execute(request)); return indexer; } diff --git a/src/NzbDrone.Core/Applications/Radarr/RadarrV3Proxy.cs b/src/NzbDrone.Core/Applications/Radarr/RadarrV3Proxy.cs index 2277f9d0e..fc1fd76c4 100644 --- a/src/NzbDrone.Core/Applications/Radarr/RadarrV3Proxy.cs +++ b/src/NzbDrone.Core/Applications/Radarr/RadarrV3Proxy.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Net; +using System.Net.Http; using FluentValidation.Results; using Newtonsoft.Json; using NLog; @@ -33,13 +34,13 @@ namespace NzbDrone.Core.Applications.Radarr public RadarrStatus GetStatus(RadarrSettings settings) { - var request = BuildRequest(settings, "/api/v3/system/status", HttpMethod.GET); + var request = BuildRequest(settings, "/api/v3/system/status", HttpMethod.Get); return Execute(request); } public List GetIndexers(RadarrSettings settings) { - var request = BuildRequest(settings, "/api/v3/indexer", HttpMethod.GET); + var request = BuildRequest(settings, "/api/v3/indexer", HttpMethod.Get); return Execute>(request); } @@ -47,7 +48,7 @@ namespace NzbDrone.Core.Applications.Radarr { try { - var request = BuildRequest(settings, $"/api/v3/indexer/{indexerId}", HttpMethod.GET); + var request = BuildRequest(settings, $"/api/v3/indexer/{indexerId}", HttpMethod.Get); return Execute(request); } catch (HttpException ex) @@ -63,19 +64,19 @@ namespace NzbDrone.Core.Applications.Radarr public void RemoveIndexer(int indexerId, RadarrSettings settings) { - var request = BuildRequest(settings, $"/api/v3/indexer/{indexerId}", HttpMethod.DELETE); + var request = BuildRequest(settings, $"/api/v3/indexer/{indexerId}", HttpMethod.Delete); _httpClient.Execute(request); } public List GetIndexerSchema(RadarrSettings settings) { - var request = BuildRequest(settings, "/api/v3/indexer/schema", HttpMethod.GET); + var request = BuildRequest(settings, "/api/v3/indexer/schema", HttpMethod.Get); return Execute>(request); } public RadarrIndexer AddIndexer(RadarrIndexer indexer, RadarrSettings settings) { - var request = BuildRequest(settings, "/api/v3/indexer", HttpMethod.POST); + var request = BuildRequest(settings, "/api/v3/indexer", HttpMethod.Post); request.SetContent(indexer.ToJson()); @@ -84,7 +85,7 @@ namespace NzbDrone.Core.Applications.Radarr public RadarrIndexer UpdateIndexer(RadarrIndexer indexer, RadarrSettings settings) { - var request = BuildRequest(settings, $"/api/v3/indexer/{indexer.Id}", HttpMethod.PUT); + var request = BuildRequest(settings, $"/api/v3/indexer/{indexer.Id}", HttpMethod.Put); request.SetContent(indexer.ToJson()); @@ -93,7 +94,7 @@ namespace NzbDrone.Core.Applications.Radarr public ValidationFailure TestConnection(RadarrIndexer indexer, RadarrSettings settings) { - var request = BuildRequest(settings, $"/api/v3/indexer/test", HttpMethod.POST); + var request = BuildRequest(settings, $"/api/v3/indexer/test", HttpMethod.Post); request.SetContent(indexer.ToJson()); diff --git a/src/NzbDrone.Core/Applications/Readarr/ReadarrV1Proxy.cs b/src/NzbDrone.Core/Applications/Readarr/ReadarrV1Proxy.cs index 64319e21d..11c764d4a 100644 --- a/src/NzbDrone.Core/Applications/Readarr/ReadarrV1Proxy.cs +++ b/src/NzbDrone.Core/Applications/Readarr/ReadarrV1Proxy.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Net; +using System.Net.Http; using FluentValidation.Results; using Newtonsoft.Json; using NLog; @@ -33,13 +34,13 @@ namespace NzbDrone.Core.Applications.Readarr public ReadarrStatus GetStatus(ReadarrSettings settings) { - var request = BuildRequest(settings, "/api/v1/system/status", HttpMethod.GET); + var request = BuildRequest(settings, "/api/v1/system/status", HttpMethod.Get); return Execute(request); } public List GetIndexers(ReadarrSettings settings) { - var request = BuildRequest(settings, "/api/v1/indexer", HttpMethod.GET); + var request = BuildRequest(settings, "/api/v1/indexer", HttpMethod.Get); return Execute>(request); } @@ -47,7 +48,7 @@ namespace NzbDrone.Core.Applications.Readarr { try { - var request = BuildRequest(settings, $"/api/v1/indexer/{indexerId}", HttpMethod.GET); + var request = BuildRequest(settings, $"/api/v1/indexer/{indexerId}", HttpMethod.Get); return Execute(request); } catch (HttpException ex) @@ -63,19 +64,19 @@ namespace NzbDrone.Core.Applications.Readarr public void RemoveIndexer(int indexerId, ReadarrSettings settings) { - var request = BuildRequest(settings, $"/api/v1/indexer/{indexerId}", HttpMethod.DELETE); + var request = BuildRequest(settings, $"/api/v1/indexer/{indexerId}", HttpMethod.Delete); _httpClient.Execute(request); } public List GetIndexerSchema(ReadarrSettings settings) { - var request = BuildRequest(settings, "/api/v1/indexer/schema", HttpMethod.GET); + var request = BuildRequest(settings, "/api/v1/indexer/schema", HttpMethod.Get); return Execute>(request); } public ReadarrIndexer AddIndexer(ReadarrIndexer indexer, ReadarrSettings settings) { - var request = BuildRequest(settings, "/api/v1/indexer", HttpMethod.POST); + var request = BuildRequest(settings, "/api/v1/indexer", HttpMethod.Post); request.SetContent(indexer.ToJson()); @@ -84,7 +85,7 @@ namespace NzbDrone.Core.Applications.Readarr public ReadarrIndexer UpdateIndexer(ReadarrIndexer indexer, ReadarrSettings settings) { - var request = BuildRequest(settings, $"/api/v1/indexer/{indexer.Id}", HttpMethod.PUT); + var request = BuildRequest(settings, $"/api/v1/indexer/{indexer.Id}", HttpMethod.Put); request.SetContent(indexer.ToJson()); @@ -93,7 +94,7 @@ namespace NzbDrone.Core.Applications.Readarr public ValidationFailure TestConnection(ReadarrIndexer indexer, ReadarrSettings settings) { - var request = BuildRequest(settings, $"/api/v1/indexer/test", HttpMethod.POST); + var request = BuildRequest(settings, $"/api/v1/indexer/test", HttpMethod.Post); request.SetContent(indexer.ToJson()); diff --git a/src/NzbDrone.Core/Applications/Sonarr/SonarrV3Proxy.cs b/src/NzbDrone.Core/Applications/Sonarr/SonarrV3Proxy.cs index a42ec5a2c..47c06f71a 100644 --- a/src/NzbDrone.Core/Applications/Sonarr/SonarrV3Proxy.cs +++ b/src/NzbDrone.Core/Applications/Sonarr/SonarrV3Proxy.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Net; +using System.Net.Http; using FluentValidation.Results; using Newtonsoft.Json; using NLog; @@ -33,13 +34,13 @@ namespace NzbDrone.Core.Applications.Sonarr public SonarrStatus GetStatus(SonarrSettings settings) { - var request = BuildRequest(settings, "/api/v3/system/status", HttpMethod.GET); + var request = BuildRequest(settings, "/api/v3/system/status", HttpMethod.Get); return Execute(request); } public List GetIndexers(SonarrSettings settings) { - var request = BuildRequest(settings, "/api/v3/indexer", HttpMethod.GET); + var request = BuildRequest(settings, "/api/v3/indexer", HttpMethod.Get); return Execute>(request); } @@ -47,7 +48,7 @@ namespace NzbDrone.Core.Applications.Sonarr { try { - var request = BuildRequest(settings, $"/api/v3/indexer/{indexerId}", HttpMethod.GET); + var request = BuildRequest(settings, $"/api/v3/indexer/{indexerId}", HttpMethod.Get); return Execute(request); } catch (HttpException ex) @@ -63,19 +64,19 @@ namespace NzbDrone.Core.Applications.Sonarr public void RemoveIndexer(int indexerId, SonarrSettings settings) { - var request = BuildRequest(settings, $"/api/v3/indexer/{indexerId}", HttpMethod.DELETE); + var request = BuildRequest(settings, $"/api/v3/indexer/{indexerId}", HttpMethod.Delete); _httpClient.Execute(request); } public List GetIndexerSchema(SonarrSettings settings) { - var request = BuildRequest(settings, "/api/v3/indexer/schema", HttpMethod.GET); + var request = BuildRequest(settings, "/api/v3/indexer/schema", HttpMethod.Get); return Execute>(request); } public SonarrIndexer AddIndexer(SonarrIndexer indexer, SonarrSettings settings) { - var request = BuildRequest(settings, "/api/v3/indexer", HttpMethod.POST); + var request = BuildRequest(settings, "/api/v3/indexer", HttpMethod.Post); request.SetContent(indexer.ToJson()); @@ -84,7 +85,7 @@ namespace NzbDrone.Core.Applications.Sonarr public SonarrIndexer UpdateIndexer(SonarrIndexer indexer, SonarrSettings settings) { - var request = BuildRequest(settings, $"/api/v3/indexer/{indexer.Id}", HttpMethod.PUT); + var request = BuildRequest(settings, $"/api/v3/indexer/{indexer.Id}", HttpMethod.Put); request.SetContent(indexer.ToJson()); @@ -93,7 +94,7 @@ namespace NzbDrone.Core.Applications.Sonarr public ValidationFailure TestConnection(SonarrIndexer indexer, SonarrSettings settings) { - var request = BuildRequest(settings, $"/api/v3/indexer/test", HttpMethod.POST); + var request = BuildRequest(settings, $"/api/v3/indexer/test", HttpMethod.Post); request.SetContent(indexer.ToJson()); diff --git a/src/NzbDrone.Core/Download/Clients/DownloadStation/Proxies/DiskStationProxyBase.cs b/src/NzbDrone.Core/Download/Clients/DownloadStation/Proxies/DiskStationProxyBase.cs index fc0837f55..213b3e505 100644 --- a/src/NzbDrone.Core/Download/Clients/DownloadStation/Proxies/DiskStationProxyBase.cs +++ b/src/NzbDrone.Core/Download/Clients/DownloadStation/Proxies/DiskStationProxyBase.cs @@ -1,6 +1,7 @@ -using System; +using System; using System.Collections.Generic; using System.Net; +using System.Net.Http; using NLog; using NzbDrone.Common.Cache; using NzbDrone.Common.Http; @@ -142,15 +143,19 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation.Proxies return authResponse.Data.SId; } - protected HttpRequestBuilder BuildRequest(DownloadStationSettings settings, string methodName, int apiVersion, HttpMethod httpVerb = HttpMethod.GET) + protected HttpRequestBuilder BuildRequest(DownloadStationSettings settings, string methodName, int apiVersion, HttpMethod httpVerb = null) { + httpVerb ??= HttpMethod.Get; + var info = GetApiInfo(_apiType, settings); return BuildRequest(settings, info, methodName, apiVersion, httpVerb); } - private HttpRequestBuilder BuildRequest(DownloadStationSettings settings, DiskStationApiInfo apiInfo, string methodName, int apiVersion, HttpMethod httpVerb = HttpMethod.GET) + private HttpRequestBuilder BuildRequest(DownloadStationSettings settings, DiskStationApiInfo apiInfo, string methodName, int apiVersion, HttpMethod httpVerb = null) { + httpVerb ??= HttpMethod.Get; + var requestBuilder = new HttpRequestBuilder(settings.UseSsl, settings.Host, settings.Port).Resource($"webapi/{apiInfo.Path}"); requestBuilder.Method = httpVerb; requestBuilder.LogResponseContent = true; @@ -163,7 +168,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation.Proxies throw new ArgumentOutOfRangeException(nameof(apiVersion)); } - if (httpVerb == HttpMethod.POST) + if (httpVerb == HttpMethod.Post) { if (apiInfo.NeedsAuthentication) { diff --git a/src/NzbDrone.Core/Download/Clients/DownloadStation/Proxies/DownloadStationTaskProxy.cs b/src/NzbDrone.Core/Download/Clients/DownloadStation/Proxies/DownloadStationTaskProxy.cs index 1e6849dac..4b5637a5c 100644 --- a/src/NzbDrone.Core/Download/Clients/DownloadStation/Proxies/DownloadStationTaskProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/DownloadStation/Proxies/DownloadStationTaskProxy.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System.Collections.Generic; +using System.Net.Http; using NLog; using NzbDrone.Common.Cache; using NzbDrone.Common.Extensions; @@ -24,7 +25,7 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation.Proxies public void AddTaskFromData(byte[] data, string filename, string downloadDirectory, DownloadStationSettings settings) { - var requestBuilder = BuildRequest(settings, "create", 2, HttpMethod.POST); + var requestBuilder = BuildRequest(settings, "create", 2, HttpMethod.Post); if (downloadDirectory.IsNotNullOrWhiteSpace()) { diff --git a/src/NzbDrone.Core/Download/Clients/Flood/FloodProxy.cs b/src/NzbDrone.Core/Download/Clients/Flood/FloodProxy.cs index ddebdbfff..06bca878f 100644 --- a/src/NzbDrone.Core/Download/Clients/Flood/FloodProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/Flood/FloodProxy.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Linq; using System.Net; +using System.Net.Http; using NLog; using NzbDrone.Common.Cache; using NzbDrone.Common.Http; @@ -107,7 +108,7 @@ namespace NzbDrone.Core.Download.Clients.Flood { var verifyRequest = BuildRequest(settings).Resource("/auth/verify").Build(); - verifyRequest.Method = HttpMethod.GET; + verifyRequest.Method = HttpMethod.Get; HandleRequest(verifyRequest, settings); } @@ -180,7 +181,7 @@ namespace NzbDrone.Core.Download.Clients.Flood { var getTorrentsRequest = BuildRequest(settings).Resource("/torrents").Build(); - getTorrentsRequest.Method = HttpMethod.GET; + getTorrentsRequest.Method = HttpMethod.Get; return Json.Deserialize(HandleRequest(getTorrentsRequest, settings).Content).Torrents; } @@ -189,7 +190,7 @@ namespace NzbDrone.Core.Download.Clients.Flood { var contentsRequest = BuildRequest(settings).Resource($"/torrents/{hash}/contents").Build(); - contentsRequest.Method = HttpMethod.GET; + contentsRequest.Method = HttpMethod.Get; return Json.Deserialize>(HandleRequest(contentsRequest, settings).Content).ConvertAll(content => content.Path); } @@ -198,7 +199,7 @@ namespace NzbDrone.Core.Download.Clients.Flood { var tagsRequest = BuildRequest(settings).Resource("/torrents/tags").Build(); - tagsRequest.Method = HttpMethod.PATCH; + tagsRequest.Method = HttpMethod.Patch; var body = new Dictionary { diff --git a/src/NzbDrone.Core/IndexerProxies/FlareSolverr/FlareSolverr.cs b/src/NzbDrone.Core/IndexerProxies/FlareSolverr/FlareSolverr.cs index 47c4c0634..23e682715 100644 --- a/src/NzbDrone.Core/IndexerProxies/FlareSolverr/FlareSolverr.cs +++ b/src/NzbDrone.Core/IndexerProxies/FlareSolverr/FlareSolverr.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Net; +using System.Net.Http; using FluentValidation.Results; using Newtonsoft.Json; using NLog; @@ -115,7 +116,7 @@ namespace NzbDrone.Core.IndexerProxies.FlareSolverr var userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36"; var maxTimeout = Settings.RequestTimeout * 1000; - if (request.Method == HttpMethod.GET) + if (request.Method == HttpMethod.Get) { req = new FlareSolverrRequestGet { @@ -125,7 +126,7 @@ namespace NzbDrone.Core.IndexerProxies.FlareSolverr UserAgent = userAgent }; } - else if (request.Method == HttpMethod.POST) + else if (request.Method == HttpMethod.Post) { var contentTypeType = request.Headers.ContentType; @@ -167,7 +168,7 @@ namespace NzbDrone.Core.IndexerProxies.FlareSolverr var newRequest = new HttpRequest(apiUrl, HttpAccept.Json); newRequest.Headers.ContentType = "application/json"; - newRequest.Method = HttpMethod.POST; + newRequest.Method = HttpMethod.Post; newRequest.SetContent(req.ToJson()); _logger.Debug("Applying FlareSolverr Proxy {0} to request {1}", Name, request.Url); diff --git a/src/NzbDrone.Core/Indexers/Definitions/Anidub.cs b/src/NzbDrone.Core/Indexers/Definitions/Anidub.cs index 6e1fe3ead..ab7aff29c 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Anidub.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Anidub.cs @@ -60,7 +60,7 @@ namespace NzbDrone.Core.Indexers.Definitions var mainPage = await ExecuteAuth(new HttpRequest(Settings.BaseUrl)); - requestBuilder.Method = Common.Http.HttpMethod.POST; + requestBuilder.Method = HttpMethod.Post; requestBuilder.PostProcess += r => r.RequestTimeout = TimeSpan.FromSeconds(15); requestBuilder.SetCookies(mainPage.GetCookies()); @@ -167,7 +167,7 @@ namespace NzbDrone.Core.Indexers.Definitions if (isSearch) { - request.HttpRequest.Method = NzbDrone.Common.Http.HttpMethod.POST; + request.HttpRequest.Method = HttpMethod.Post; var postData = new NameValueCollection { { "do", "search" }, diff --git a/src/NzbDrone.Core/Indexers/Definitions/AnimeTorrents.cs b/src/NzbDrone.Core/Indexers/Definitions/AnimeTorrents.cs index 0e0b59de6..87c92d73a 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/AnimeTorrents.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/AnimeTorrents.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Collections.Specialized; using System.Globalization; using System.Linq; +using System.Net.Http; using System.Text.RegularExpressions; using System.Threading.Tasks; using AngleSharp.Html.Parser; @@ -57,7 +58,7 @@ namespace NzbDrone.Core.Indexers.Definitions }; var loginPage = await ExecuteAuth(new HttpRequest(LoginUrl)); - requestBuilder.Method = HttpMethod.POST; + requestBuilder.Method = HttpMethod.Post; requestBuilder.PostProcess += r => r.RequestTimeout = TimeSpan.FromSeconds(15); requestBuilder.SetCookies(loginPage.GetCookies()); diff --git a/src/NzbDrone.Core/Indexers/Definitions/Anthelion.cs b/src/NzbDrone.Core/Indexers/Definitions/Anthelion.cs index b52b49a14..e4d2597fe 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Anthelion.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Anthelion.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; +using System.Net.Http; using System.Text; using System.Threading.Tasks; using AngleSharp.Html.Parser; @@ -56,7 +57,7 @@ namespace NzbDrone.Core.Indexers.Definitions AllowAutoRedirect = true }; - requestBuilder.Method = HttpMethod.POST; + requestBuilder.Method = HttpMethod.Post; requestBuilder.PostProcess += r => r.RequestTimeout = TimeSpan.FromSeconds(15); var cookies = Cookies; diff --git a/src/NzbDrone.Core/Indexers/Definitions/Avistaz/AvistazBase.cs b/src/NzbDrone.Core/Indexers/Definitions/Avistaz/AvistazBase.cs index f231fae7c..3663f1250 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Avistaz/AvistazBase.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Avistaz/AvistazBase.cs @@ -1,5 +1,6 @@ using System; using System.Net; +using System.Net.Http; using System.Threading.Tasks; using FluentValidation.Results; using NLog; @@ -105,7 +106,7 @@ namespace NzbDrone.Core.Indexers.Definitions.Avistaz LogResponseContent = true }; - requestBuilder.Method = HttpMethod.POST; + requestBuilder.Method = HttpMethod.Post; requestBuilder.PostProcess += r => r.RequestTimeout = TimeSpan.FromSeconds(15); var authLoginRequest = requestBuilder diff --git a/src/NzbDrone.Core/Indexers/Definitions/BB.cs b/src/NzbDrone.Core/Indexers/Definitions/BB.cs index 4c44c5b6c..e849cfade 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/BB.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/BB.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Collections.Specialized; +using System.Net.Http; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; @@ -55,7 +56,7 @@ namespace NzbDrone.Core.Indexers.Definitions AllowAutoRedirect = true }; - requestBuilder.Method = HttpMethod.POST; + requestBuilder.Method = HttpMethod.Post; requestBuilder.PostProcess += r => r.RequestTimeout = TimeSpan.FromSeconds(15); var cookies = Cookies; diff --git a/src/NzbDrone.Core/Indexers/Definitions/BakaBT.cs b/src/NzbDrone.Core/Indexers/Definitions/BakaBT.cs index eb964df8c..8595a16d1 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/BakaBT.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/BakaBT.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Net; +using System.Net.Http; using System.Text.RegularExpressions; using System.Threading.Tasks; using AngleSharp.Dom; @@ -79,7 +80,7 @@ namespace NzbDrone.Core.Indexers.Definitions var loginPage = await ExecuteAuth(new HttpRequest(LoginUrl)); - requestBuilder.Method = HttpMethod.POST; + requestBuilder.Method = HttpMethod.Post; requestBuilder.PostProcess += r => r.RequestTimeout = TimeSpan.FromSeconds(15); requestBuilder.SetCookies(loginPage.GetCookies()); diff --git a/src/NzbDrone.Core/Indexers/Definitions/BeyondHD.cs b/src/NzbDrone.Core/Indexers/Definitions/BeyondHD.cs index acda788be..e3c0fc054 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/BeyondHD.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/BeyondHD.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Net; +using System.Net.Http; using FluentValidation; using Newtonsoft.Json; using NLog; @@ -110,7 +111,7 @@ namespace NzbDrone.Core.Indexers.Definitions var request = new HttpRequest(searchUrl, HttpAccept.Json); request.Headers.Add("Content-type", "application/json"); - request.Method = HttpMethod.POST; + request.Method = HttpMethod.Post; request.SetContent(body.ToJson()); var indexerRequest = new IndexerRequest(request); diff --git a/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannRequestGenerator.cs index 1bd0a6c76..2622142cd 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannRequestGenerator.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; using System.Net; +using System.Net.Http; using System.Text; using System.Threading.Tasks; using AngleSharp.Html.Dom; @@ -184,7 +185,7 @@ namespace NzbDrone.Core.Indexers.Cardigann var requestBuilder = new HttpRequestBuilder(loginUrl) { LogResponseContent = true, - Method = HttpMethod.POST, + Method = HttpMethod.Post, AllowAutoRedirect = true, SuppressHttpError = true, Encoding = _encoding @@ -329,7 +330,7 @@ namespace NzbDrone.Core.Indexers.Cardigann var requestBuilder = new HttpRequestBuilder(captchaUrl.ToString()) { LogResponseContent = true, - Method = HttpMethod.GET, + Method = HttpMethod.Get, Encoding = _encoding }; @@ -394,7 +395,7 @@ namespace NzbDrone.Core.Indexers.Cardigann var requestBuilder = new HttpRequestBuilder(submitUrl.ToString()) { LogResponseContent = true, - Method = HttpMethod.POST, + Method = HttpMethod.Post, AllowAutoRedirect = true, Encoding = _encoding }; @@ -423,7 +424,7 @@ namespace NzbDrone.Core.Indexers.Cardigann var requestBuilder = new HttpRequestBuilder(submitUrl.ToString()) { LogResponseContent = true, - Method = HttpMethod.POST, + Method = HttpMethod.Post, AllowAutoRedirect = true, SuppressHttpError = true, Encoding = _encoding @@ -466,7 +467,7 @@ namespace NzbDrone.Core.Indexers.Cardigann var requestBuilder = new HttpRequestBuilder(loginUrl) { LogResponseContent = true, - Method = HttpMethod.GET, + Method = HttpMethod.Get, SuppressHttpError = true, Encoding = _encoding }; @@ -491,7 +492,7 @@ namespace NzbDrone.Core.Indexers.Cardigann var requestBuilder = new HttpRequestBuilder(loginUrl) { LogResponseContent = true, - Method = HttpMethod.GET, + Method = HttpMethod.Get, SuppressHttpError = true, Encoding = _encoding }; @@ -565,7 +566,7 @@ namespace NzbDrone.Core.Indexers.Cardigann var requestBuilder = new HttpRequestBuilder(loginUrl.AbsoluteUri) { LogResponseContent = true, - Method = HttpMethod.GET, + Method = HttpMethod.Get, Encoding = _encoding }; @@ -666,21 +667,21 @@ namespace NzbDrone.Core.Indexers.Cardigann Dictionary pairs = null; var queryCollection = new NameValueCollection(); - var method = HttpMethod.GET; + var method = HttpMethod.Get; if (string.Equals(request.Method, "post", StringComparison.OrdinalIgnoreCase)) { - method = HttpMethod.POST; + method = HttpMethod.Post; pairs = new Dictionary(); } foreach (var input in request.Inputs) { var value = ApplyGoTemplateText(input.Value, variables); - if (method == HttpMethod.GET) + if (method == HttpMethod.Get) { queryCollection.Add(input.Key, value); } - else if (method == HttpMethod.POST) + else if (method == HttpMethod.Post) { pairs.Add(input.Key, value); } @@ -707,7 +708,7 @@ namespace NzbDrone.Core.Indexers.Cardigann httpRequest.Method = method; // Add form data for POST requests - if (method == HttpMethod.POST) + if (method == HttpMethod.Post) { foreach (var param in pairs) { @@ -724,7 +725,7 @@ namespace NzbDrone.Core.Indexers.Cardigann public async Task DownloadRequest(Uri link) { Cookies = GetCookies(); - var method = HttpMethod.GET; + var method = HttpMethod.Get; var headers = new Dictionary(); var variables = GetBaseTemplateVariables(); @@ -759,7 +760,7 @@ namespace NzbDrone.Core.Indexers.Cardigann if (download.Method == "post") { - method = HttpMethod.POST; + method = HttpMethod.Post; } if (download.Infohash != null) @@ -1014,11 +1015,11 @@ namespace NzbDrone.Core.Indexers.Cardigann // HttpUtility.UrlPathEncode seems to only encode spaces, we use UrlEncode and replace + with %20 as a workaround var searchUrl = ResolvePath(ApplyGoTemplateText(searchPath.Path, variables, WebUtility.UrlEncode).Replace("+", "%20")).AbsoluteUri; var queryCollection = new List>(); - var method = HttpMethod.GET; + var method = HttpMethod.Get; if (string.Equals(searchPath.Method, "post", StringComparison.OrdinalIgnoreCase)) { - method = HttpMethod.POST; + method = HttpMethod.Post; } var inputsList = new List>(); @@ -1064,7 +1065,7 @@ namespace NzbDrone.Core.Indexers.Cardigann } } - if (method == HttpMethod.GET) + if (method == HttpMethod.Get) { if (queryCollection.Count > 0) { @@ -1079,7 +1080,7 @@ namespace NzbDrone.Core.Indexers.Cardigann requestbuilder.Method = method; // Add FormData for searchs that POST - if (method == HttpMethod.POST) + if (method == HttpMethod.Post) { foreach (var param in queryCollection) { diff --git a/src/NzbDrone.Core/Indexers/Definitions/Gazelle/Gazelle.cs b/src/NzbDrone.Core/Indexers/Definitions/Gazelle/Gazelle.cs index bf316f438..a30436849 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Gazelle/Gazelle.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Gazelle/Gazelle.cs @@ -1,4 +1,5 @@ using System; +using System.Net.Http; using System.Threading.Tasks; using NLog; using NzbDrone.Common.Http; @@ -56,7 +57,7 @@ namespace NzbDrone.Core.Indexers.Gazelle LogResponseContent = true }; - requestBuilder.Method = HttpMethod.POST; + requestBuilder.Method = HttpMethod.Post; requestBuilder.PostProcess += r => r.RequestTimeout = TimeSpan.FromSeconds(15); var cookies = Cookies; diff --git a/src/NzbDrone.Core/Indexers/Definitions/HDBits/HDBitsRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Definitions/HDBits/HDBitsRequestGenerator.cs index 8c486c673..807ee5b75 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/HDBits/HDBitsRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/HDBits/HDBitsRequestGenerator.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Net.Http; using NzbDrone.Common.Extensions; using NzbDrone.Common.Http; using NzbDrone.Common.Serializer; @@ -50,7 +51,7 @@ namespace NzbDrone.Core.Indexers.HDBits .Resource("/api/torrents") .Build(); - request.Method = HttpMethod.POST; + request.Method = HttpMethod.Post; const string appJson = "application/json"; request.Headers.Accept = appJson; request.Headers.ContentType = appJson; diff --git a/src/NzbDrone.Core/Indexers/Definitions/HDSpace.cs b/src/NzbDrone.Core/Indexers/Definitions/HDSpace.cs index e4742cc0e..9bae17112 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/HDSpace.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/HDSpace.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; +using System.Net.Http; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; @@ -57,7 +58,7 @@ namespace NzbDrone.Core.Indexers.Definitions AllowAutoRedirect = true }; - requestBuilder.Method = HttpMethod.POST; + requestBuilder.Method = HttpMethod.Post; requestBuilder.PostProcess += r => r.RequestTimeout = TimeSpan.FromSeconds(15); var cookies = Cookies; diff --git a/src/NzbDrone.Core/Indexers/Definitions/HDTorrents.cs b/src/NzbDrone.Core/Indexers/Definitions/HDTorrents.cs index a7f59e159..e7957c0ea 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/HDTorrents.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/HDTorrents.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Collections.Specialized; using System.Globalization; using System.Linq; +using System.Net.Http; using System.Text.RegularExpressions; using System.Threading.Tasks; using AngleSharp.Html.Parser; @@ -52,7 +53,7 @@ namespace NzbDrone.Core.Indexers.Definitions LogResponseContent = true }; - requestBuilder.Method = HttpMethod.POST; + requestBuilder.Method = HttpMethod.Post; requestBuilder.PostProcess += r => r.RequestTimeout = TimeSpan.FromSeconds(15); var cookies = Cookies; diff --git a/src/NzbDrone.Core/Indexers/Definitions/ImmortalSeed.cs b/src/NzbDrone.Core/Indexers/Definitions/ImmortalSeed.cs index 29224d5a6..59d3bb07d 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/ImmortalSeed.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/ImmortalSeed.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Net; +using System.Net.Http; using System.Threading.Tasks; using AngleSharp.Html.Parser; using FluentValidation; @@ -54,7 +55,7 @@ namespace NzbDrone.Core.Indexers.Definitions LogResponseContent = true }; - requestBuilder.Method = HttpMethod.POST; + requestBuilder.Method = HttpMethod.Post; requestBuilder.PostProcess += r => r.RequestTimeout = TimeSpan.FromSeconds(15); var cookies = Cookies; diff --git a/src/NzbDrone.Core/Indexers/Definitions/Nebulance.cs b/src/NzbDrone.Core/Indexers/Definitions/Nebulance.cs index a3b1da8ab..4d6d231c6 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Nebulance.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Nebulance.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Collections.Specialized; using System.Globalization; +using System.Net.Http; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; @@ -53,7 +54,7 @@ namespace NzbDrone.Core.Indexers.Definitions LogResponseContent = true }; - requestBuilder.Method = HttpMethod.POST; + requestBuilder.Method = HttpMethod.Post; requestBuilder.PostProcess += r => r.RequestTimeout = TimeSpan.FromSeconds(15); var cookies = Cookies; diff --git a/src/NzbDrone.Core/Indexers/Definitions/Newznab/NewznabCapabilitiesProvider.cs b/src/NzbDrone.Core/Indexers/Definitions/Newznab/NewznabCapabilitiesProvider.cs index 29911e7db..155ec309a 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Newznab/NewznabCapabilitiesProvider.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Newznab/NewznabCapabilitiesProvider.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Net.Http; using System.Xml; using System.Xml.Linq; using NLog; @@ -50,7 +51,7 @@ namespace NzbDrone.Core.Indexers.Newznab var request = new HttpRequest(url, HttpAccept.Rss); request.AllowAutoRedirect = true; - request.Method = HttpMethod.GET; + request.Method = HttpMethod.Get; HttpResponse response; diff --git a/src/NzbDrone.Core/Indexers/Definitions/NorBits.cs b/src/NzbDrone.Core/Indexers/Definitions/NorBits.cs index 2ab60205e..392fedc67 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/NorBits.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/NorBits.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Collections.Specialized; using System.Globalization; using System.Linq; +using System.Net.Http; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; @@ -79,7 +80,7 @@ namespace NzbDrone.Core.Indexers.Definitions { LogResponseContent = true, AllowAutoRedirect = true, - Method = HttpMethod.POST + Method = HttpMethod.Post }; var authLoginCheckRequest = requestBuilder3 diff --git a/src/NzbDrone.Core/Indexers/Definitions/PornoLab.cs b/src/NzbDrone.Core/Indexers/Definitions/PornoLab.cs index f5a7092a9..dfb3f0a35 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/PornoLab.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/PornoLab.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Net.Http; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; @@ -52,7 +53,7 @@ namespace NzbDrone.Core.Indexers.Definitions { LogResponseContent = true, AllowAutoRedirect = true, - Method = HttpMethod.POST + Method = HttpMethod.Post }; var authLoginRequest = requestBuilder diff --git a/src/NzbDrone.Core/Indexers/Definitions/PreToMe.cs b/src/NzbDrone.Core/Indexers/Definitions/PreToMe.cs index 4033a23f2..e80dbad09 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/PreToMe.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/PreToMe.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Net.Http; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; @@ -59,7 +60,7 @@ namespace NzbDrone.Core.Indexers.Definitions var loginPage = await ExecuteAuth(new HttpRequest(Settings.BaseUrl + "login.php")); - requestBuilder.Method = HttpMethod.POST; + requestBuilder.Method = HttpMethod.Post; requestBuilder.PostProcess += r => r.RequestTimeout = TimeSpan.FromSeconds(15); requestBuilder.SetCookies(loginPage.GetCookies()); diff --git a/src/NzbDrone.Core/Indexers/Definitions/RevolutionTT.cs b/src/NzbDrone.Core/Indexers/Definitions/RevolutionTT.cs index d7de77b4a..7c48ab38f 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/RevolutionTT.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/RevolutionTT.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Collections.Specialized; using System.Globalization; using System.Linq; +using System.Net.Http; using System.Threading.Tasks; using AngleSharp.Html.Parser; using FluentValidation; @@ -58,7 +59,7 @@ namespace NzbDrone.Core.Indexers.Definitions var loginPage = await ExecuteAuth(new HttpRequest(Settings.BaseUrl + "login.php")); - requestBuilder.Method = HttpMethod.POST; + requestBuilder.Method = HttpMethod.Post; requestBuilder.PostProcess += r => r.RequestTimeout = TimeSpan.FromSeconds(15); requestBuilder.SetCookies(loginPage.GetCookies()); diff --git a/src/NzbDrone.Core/Indexers/Definitions/RuTracker.cs b/src/NzbDrone.Core/Indexers/Definitions/RuTracker.cs index c45cd1b8d..bcd4084e7 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/RuTracker.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/RuTracker.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; +using System.Net.Http; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; @@ -57,7 +58,7 @@ namespace NzbDrone.Core.Indexers.Definitions AllowAutoRedirect = true }; - requestBuilder.Method = HttpMethod.POST; + requestBuilder.Method = HttpMethod.Post; requestBuilder.PostProcess += r => r.RequestTimeout = TimeSpan.FromSeconds(15); var cookies = Cookies; diff --git a/src/NzbDrone.Core/Indexers/Definitions/SpeedApp.cs b/src/NzbDrone.Core/Indexers/Definitions/SpeedApp.cs index f9dd987fa..67e393e39 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/SpeedApp.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/SpeedApp.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; using System.Net; +using System.Net.Http; using System.Net.Mime; using System.Text; using System.Threading.Tasks; @@ -75,7 +76,7 @@ namespace NzbDrone.Core.Indexers.Definitions { LogResponseContent = true, AllowAutoRedirect = true, - Method = HttpMethod.POST, + Method = HttpMethod.Post, }; var request = requestBuilder.Build(); diff --git a/src/NzbDrone.Core/Indexers/Definitions/SpeedCD.cs b/src/NzbDrone.Core/Indexers/Definitions/SpeedCD.cs index ef253a5eb..04b176a0a 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/SpeedCD.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/SpeedCD.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Globalization; using System.Linq; +using System.Net.Http; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; @@ -57,7 +58,7 @@ namespace NzbDrone.Core.Indexers.Definitions { var requestBuilder = new HttpRequestBuilder(string.Format("{0}/{1}", Settings.BaseUrl.TrimEnd('/'), "checkpoint/API")) { - Method = HttpMethod.POST, + Method = HttpMethod.Post, LogResponseContent = true, AllowAutoRedirect = true }; @@ -77,7 +78,7 @@ namespace NzbDrone.Core.Indexers.Definitions var requestBuilder2 = new HttpRequestBuilder(string.Format("{0}/{1}", Settings.BaseUrl.TrimEnd('/'), "checkpoint/")) { - Method = HttpMethod.POST, + Method = HttpMethod.Post, LogResponseContent = true, AllowAutoRedirect = true }; diff --git a/src/NzbDrone.Core/Indexers/Definitions/TVVault.cs b/src/NzbDrone.Core/Indexers/Definitions/TVVault.cs index 5fc618a90..1d56f6110 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/TVVault.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/TVVault.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; +using System.Net.Http; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; @@ -59,7 +60,7 @@ namespace NzbDrone.Core.Indexers.Definitions AllowAutoRedirect = true }; - requestBuilder.Method = HttpMethod.POST; + requestBuilder.Method = HttpMethod.Post; var cookies = Cookies; diff --git a/src/NzbDrone.Core/Indexers/Definitions/TorrentLeech.cs b/src/NzbDrone.Core/Indexers/Definitions/TorrentLeech.cs index 3152fc1eb..065ab7481 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/TorrentLeech.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/TorrentLeech.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Net; +using System.Net.Http; using System.Text.RegularExpressions; using System.Threading.Tasks; using FluentValidation; @@ -54,7 +55,7 @@ namespace NzbDrone.Core.Indexers.Definitions LogResponseContent = true }; - requestBuilder.Method = HttpMethod.POST; + requestBuilder.Method = HttpMethod.Post; requestBuilder.PostProcess += r => r.RequestTimeout = TimeSpan.FromSeconds(15); var cookies = Cookies; diff --git a/src/NzbDrone.Core/Indexers/Definitions/TorrentSeeds.cs b/src/NzbDrone.Core/Indexers/Definitions/TorrentSeeds.cs index 6fdf85976..87cca4876 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/TorrentSeeds.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/TorrentSeeds.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; using System.Net; +using System.Net.Http; using System.Text.RegularExpressions; using System.Threading.Tasks; using AngleSharp.Html.Parser; @@ -63,7 +64,7 @@ namespace NzbDrone.Core.Indexers.Definitions var json1 = JObject.Parse(loginPage.Content); var captchaSelection = json1["images"][0]["hash"]; - requestBuilder.Method = HttpMethod.POST; + requestBuilder.Method = HttpMethod.Post; requestBuilder.PostProcess += r => r.RequestTimeout = TimeSpan.FromSeconds(15); requestBuilder.SetCookies(loginPage.GetCookies()); diff --git a/src/NzbDrone.Core/Indexers/Definitions/ZonaQ.cs b/src/NzbDrone.Core/Indexers/Definitions/ZonaQ.cs index 6e1233841..48497b75a 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/ZonaQ.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/ZonaQ.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Collections.Specialized; using System.Globalization; using System.Linq; +using System.Net.Http; using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; @@ -79,7 +80,7 @@ namespace NzbDrone.Core.Indexers.Definitions LogResponseContent = true }; - requestBuilder.Method = HttpMethod.POST; + requestBuilder.Method = HttpMethod.Post; requestBuilder.PostProcess += r => r.RequestTimeout = TimeSpan.FromSeconds(15); requestBuilder.SetCookies(loginPage.GetCookies()); @@ -102,7 +103,7 @@ namespace NzbDrone.Core.Indexers.Definitions LogResponseContent = true }; - requestBuilder2.Method = HttpMethod.POST; + requestBuilder2.Method = HttpMethod.Post; requestBuilder2.PostProcess += r => r.RequestTimeout = TimeSpan.FromSeconds(15); requestBuilder2.SetCookies(response.GetCookies()); diff --git a/src/NzbDrone.Core/Notifications/Discord/DiscordProxy.cs b/src/NzbDrone.Core/Notifications/Discord/DiscordProxy.cs index f3a6be3d2..c066da569 100644 --- a/src/NzbDrone.Core/Notifications/Discord/DiscordProxy.cs +++ b/src/NzbDrone.Core/Notifications/Discord/DiscordProxy.cs @@ -1,3 +1,4 @@ +using System.Net.Http; using NLog; using NzbDrone.Common.Http; using NzbDrone.Common.Serializer; @@ -29,7 +30,7 @@ namespace NzbDrone.Core.Notifications.Discord .Accept(HttpAccept.Json) .Build(); - request.Method = HttpMethod.POST; + request.Method = HttpMethod.Post; request.Headers.ContentType = "application/json"; request.SetContent(payload.ToJson()); diff --git a/src/NzbDrone.Core/Notifications/Join/JoinProxy.cs b/src/NzbDrone.Core/Notifications/Join/JoinProxy.cs index 7c901100e..aa477fbdd 100644 --- a/src/NzbDrone.Core/Notifications/Join/JoinProxy.cs +++ b/src/NzbDrone.Core/Notifications/Join/JoinProxy.cs @@ -1,4 +1,5 @@ using System; +using System.Net.Http; using FluentValidation.Results; using NLog; using NzbDrone.Common.Extensions; @@ -27,7 +28,7 @@ namespace NzbDrone.Core.Notifications.Join public void SendNotification(string title, string message, JoinSettings settings) { - var method = HttpMethod.GET; + var method = HttpMethod.Get; try { diff --git a/src/NzbDrone.Core/Notifications/PushBullet/PushBulletProxy.cs b/src/NzbDrone.Core/Notifications/PushBullet/PushBulletProxy.cs index 074d5578f..f39382ae8 100644 --- a/src/NzbDrone.Core/Notifications/PushBullet/PushBulletProxy.cs +++ b/src/NzbDrone.Core/Notifications/PushBullet/PushBulletProxy.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Net; +using System.Net.Http; using FluentValidation.Results; using NLog; using NzbDrone.Common.Extensions; @@ -100,7 +101,7 @@ namespace NzbDrone.Core.Notifications.PushBullet var request = requestBuilder.Build(); - request.Method = HttpMethod.GET; + request.Method = HttpMethod.Get; request.AddBasicAuthentication(settings.ApiKey, string.Empty); var response = _httpClient.Execute(request); diff --git a/src/NzbDrone.Core/Notifications/SendGrid/SendGridProxy.cs b/src/NzbDrone.Core/Notifications/SendGrid/SendGridProxy.cs index a8a44ef11..6a3b41ca9 100644 --- a/src/NzbDrone.Core/Notifications/SendGrid/SendGridProxy.cs +++ b/src/NzbDrone.Core/Notifications/SendGrid/SendGridProxy.cs @@ -1,4 +1,5 @@ using System.Net; +using System.Net.Http; using NzbDrone.Common.Http; using NzbDrone.Common.Serializer; @@ -22,7 +23,7 @@ namespace NzbDrone.Core.Notifications.SendGrid { try { - var request = BuildRequest(settings, "mail/send", HttpMethod.POST); + var request = BuildRequest(settings, "mail/send", HttpMethod.Post); var payload = new SendGridPayload { diff --git a/src/NzbDrone.Core/Notifications/Slack/SlackProxy.cs b/src/NzbDrone.Core/Notifications/Slack/SlackProxy.cs index 02075dad9..c8dd12f53 100644 --- a/src/NzbDrone.Core/Notifications/Slack/SlackProxy.cs +++ b/src/NzbDrone.Core/Notifications/Slack/SlackProxy.cs @@ -1,3 +1,4 @@ +using System.Net.Http; using NLog; using NzbDrone.Common.Http; using NzbDrone.Common.Serializer; @@ -29,7 +30,7 @@ namespace NzbDrone.Core.Notifications.Slack .Accept(HttpAccept.Json) .Build(); - request.Method = HttpMethod.POST; + request.Method = HttpMethod.Post; request.Headers.ContentType = "application/json"; request.SetContent(payload.ToJson()); diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookMethod.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookMethod.cs index 5d6e859a6..a3f594bf7 100755 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookMethod.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookMethod.cs @@ -1,10 +1,11 @@ +using System.Net.Http; using NzbDrone.Common.Http; namespace NzbDrone.Core.Notifications.Webhook { public enum WebhookMethod { - POST = HttpMethod.POST, - PUT = HttpMethod.PUT + POST = 1, + PUT = 2 } } diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookProxy.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookProxy.cs index 489eeb41f..d196b5579 100755 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookProxy.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookProxy.cs @@ -1,3 +1,5 @@ +using System; +using System.Net.Http; using NzbDrone.Common.Extensions; using NzbDrone.Common.Http; using NzbDrone.Common.Serializer; @@ -26,7 +28,13 @@ namespace NzbDrone.Core.Notifications.Webhook .Accept(HttpAccept.Json) .Build(); - request.Method = (HttpMethod)settings.Method; + request.Method = settings.Method switch + { + (int)WebhookMethod.POST => HttpMethod.Post, + (int)WebhookMethod.PUT => HttpMethod.Put, + _ => throw new ArgumentOutOfRangeException($"Invalid Webhook method {settings.Method}") + }; + request.Headers.ContentType = "application/json"; request.SetContent(body.ToJson());