diff --git a/src/NzbDrone.Common/Http/HttpClient.cs b/src/NzbDrone.Common/Http/HttpClient.cs index e3953665c..8a912c473 100644 --- a/src/NzbDrone.Common/Http/HttpClient.cs +++ b/src/NzbDrone.Common/Http/HttpClient.cs @@ -216,7 +216,7 @@ namespace NzbDrone.Common.Http private void HandleResponseCookies(HttpResponse response, CookieContainer cookieContainer) { - var cookieHeaders = response.Cookies; + var cookieHeaders = response.GetCookieHeaders(); if (cookieHeaders.Empty()) { return; @@ -228,11 +228,11 @@ namespace NzbDrone.Common.Http { var persistentCookieContainer = _cookieContainerCache.Get("container", () => new CookieContainer()); - foreach (Cookie cookieHeader in cookieHeaders) + foreach (var cookieHeader in cookieHeaders) { try { - persistentCookieContainer.Add((Uri)response.Request.Url, cookieHeader); + persistentCookieContainer.SetCookies((Uri)response.Request.Url, cookieHeader); } catch (Exception ex) { diff --git a/src/NzbDrone.Common/Http/HttpResponse.cs b/src/NzbDrone.Common/Http/HttpResponse.cs index db498e186..85ebe9ffc 100644 --- a/src/NzbDrone.Common/Http/HttpResponse.cs +++ b/src/NzbDrone.Common/Http/HttpResponse.cs @@ -59,6 +59,11 @@ namespace NzbDrone.Common.Http StatusCode == HttpStatusCode.TemporaryRedirect || StatusCode == HttpStatusCode.Found; + public string[] GetCookieHeaders() + { + return Headers.GetValues("Set-Cookie") ?? Array.Empty(); + } + public Dictionary GetCookies() { var result = new Dictionary();