diff --git a/src/NzbDrone.Common/Http/Dispatchers/ManagedHttpDispatcher.cs b/src/NzbDrone.Common/Http/Dispatchers/ManagedHttpDispatcher.cs index eb735bf7a..72aa23033 100644 --- a/src/NzbDrone.Common/Http/Dispatchers/ManagedHttpDispatcher.cs +++ b/src/NzbDrone.Common/Http/Dispatchers/ManagedHttpDispatcher.cs @@ -20,7 +20,6 @@ public HttpResponse GetResponse(HttpRequest request, CookieContainer cookies) webRequest.UserAgent = UserAgentBuilder.UserAgent; webRequest.KeepAlive = false; webRequest.AllowAutoRedirect = request.AllowAutoRedirect; - webRequest.ContentLength = 0; webRequest.CookieContainer = cookies; if (request.NetworkCredential != null) diff --git a/src/NzbDrone.Core/Download/Clients/qBittorrent/QBittorrentProxy.cs b/src/NzbDrone.Core/Download/Clients/qBittorrent/QBittorrentProxy.cs index 44436688f..2e4d2df4a 100644 --- a/src/NzbDrone.Core/Download/Clients/qBittorrent/QBittorrentProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/qBittorrent/QBittorrentProxy.cs @@ -3,6 +3,7 @@ using System.Net; using NLog; using NzbDrone.Common.Cache; +using NzbDrone.Common.Extensions; using NzbDrone.Common.Http; using NzbDrone.Common.Serializer; @@ -68,7 +69,7 @@ public void AddTorrentFromUrl(string torrentUrl, QBittorrentSettings settings) { var request = BuildRequest(settings).Resource("/command/download") .Post() - .AddQueryParam("urls", torrentUrl); + .AddFormParameter("urls", torrentUrl); ProcessRequest(request, settings); } @@ -168,6 +169,11 @@ private TResult ProcessRequest(HttpRequestBuilder requestBuilder, QBitt private void AuthenticateClient(HttpRequestBuilder requestBuilder, QBittorrentSettings settings, bool reauthenticate = false) { + if (settings.Username.IsNullOrWhiteSpace() || settings.Password.IsNullOrWhiteSpace()) + { + return; + } + var authKey = string.Format("{0}:{1}", requestBuilder.BaseUrl, settings.Password); var cookies = _authCookieCache.Find(authKey); @@ -177,10 +183,10 @@ private void AuthenticateClient(HttpRequestBuilder requestBuilder, QBittorrentSe _authCookieCache.Remove(authKey); var authLoginRequest = BuildRequest(settings).Resource("/login") - .Post() - .AddFormParameter("username", settings.Username) - .AddFormParameter("password", settings.Password) - .Build(); + .Post() + .AddFormParameter("username", settings.Username ?? string.Empty) + .AddFormParameter("password", settings.Password ?? string.Empty) + .Build(); HttpResponse response; try