Revert "Cleanup Cookie handling in HttpClient"

This reverts commit d932beba50.
pull/25/head
Qstick 4 years ago
parent fa7647135b
commit 15de46c877

@ -216,7 +216,7 @@ namespace NzbDrone.Common.Http
private void HandleResponseCookies(HttpResponse response, CookieContainer cookieContainer) private void HandleResponseCookies(HttpResponse response, CookieContainer cookieContainer)
{ {
var cookieHeaders = response.Cookies; var cookieHeaders = response.GetCookieHeaders();
if (cookieHeaders.Empty()) if (cookieHeaders.Empty())
{ {
return; return;
@ -228,11 +228,11 @@ namespace NzbDrone.Common.Http
{ {
var persistentCookieContainer = _cookieContainerCache.Get("container", () => new CookieContainer()); var persistentCookieContainer = _cookieContainerCache.Get("container", () => new CookieContainer());
foreach (Cookie cookieHeader in cookieHeaders) foreach (var cookieHeader in cookieHeaders)
{ {
try try
{ {
persistentCookieContainer.Add((Uri)response.Request.Url, cookieHeader); persistentCookieContainer.SetCookies((Uri)response.Request.Url, cookieHeader);
} }
catch (Exception ex) catch (Exception ex)
{ {

@ -59,6 +59,11 @@ namespace NzbDrone.Common.Http
StatusCode == HttpStatusCode.TemporaryRedirect || StatusCode == HttpStatusCode.TemporaryRedirect ||
StatusCode == HttpStatusCode.Found; StatusCode == HttpStatusCode.Found;
public string[] GetCookieHeaders()
{
return Headers.GetValues("Set-Cookie") ?? Array.Empty<string>();
}
public Dictionary<string, string> GetCookies() public Dictionary<string, string> GetCookies()
{ {
var result = new Dictionary<string, string>(); var result = new Dictionary<string, string>();

Loading…
Cancel
Save