diff --git a/src/NzbDrone.Common/Http/HttpResponse.cs b/src/NzbDrone.Common/Http/HttpResponse.cs index 9969c2bdc..181dc10d7 100644 --- a/src/NzbDrone.Common/Http/HttpResponse.cs +++ b/src/NzbDrone.Common/Http/HttpResponse.cs @@ -62,6 +62,20 @@ public string Content StatusCode == HttpStatusCode.TemporaryRedirect || StatusCode == HttpStatusCode.Found; + public string RedirectUrl + { + get + { + var newUrl = Headers["Location"]; + if (newUrl == null || newUrl.IsNullOrWhiteSpace()) + { + return string.Empty; + } + + return (Request.Url += new HttpUri(newUrl)).FullUri; + } + } + public string[] GetCookieHeaders() { return Headers.GetValues("Set-Cookie") ?? Array.Empty(); diff --git a/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannParser.cs b/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannParser.cs index ab343f4d7..72b519276 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannParser.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannParser.cs @@ -36,7 +36,7 @@ public IList ParseResponse(IndexerResponse indexerResponse) if (indexerResponse.HttpResponse.StatusCode != HttpStatusCode.OK) { // Remove cookie cache - if (indexerResponse.HttpResponse.HasHttpRedirect && indexerResponse.HttpResponse.Headers["Location"] + if (indexerResponse.HttpResponse.HasHttpRedirect && indexerResponse.HttpResponse.RedirectUrl .ContainsIgnoreCase("login.php")) { CookiesUpdater(null, null); diff --git a/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannRequestGenerator.cs b/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannRequestGenerator.cs index 17eadaf8b..9607289d3 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannRequestGenerator.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Cardigann/CardigannRequestGenerator.cs @@ -635,14 +635,14 @@ protected string GetRedirectDomainHint(string requestUrl, string redirectUrl) { if (requestUrl.StartsWith(SiteLink) && !redirectUrl.StartsWith(SiteLink)) { - var uri = new Uri(redirectUrl); + var uri = new HttpUri(redirectUrl); return uri.Scheme + "://" + uri.Host + "/"; } return null; } - protected string GetRedirectDomainHint(HttpResponse result) => GetRedirectDomainHint(result.Request.Url.ToString(), result.Headers.GetSingleValue("Location")); + protected string GetRedirectDomainHint(HttpResponse result) => GetRedirectDomainHint(result.Request.Url.ToString(), result.RedirectUrl); protected async Task HandleRequest(RequestBlock request, Dictionary variables = null, string referer = null) { diff --git a/src/NzbDrone.Core/Indexers/Definitions/PassThePopcorn/PassThePopcornParser.cs b/src/NzbDrone.Core/Indexers/Definitions/PassThePopcorn/PassThePopcornParser.cs index 1f575a8ed..778db934f 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/PassThePopcorn/PassThePopcornParser.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/PassThePopcorn/PassThePopcornParser.cs @@ -29,7 +29,7 @@ public IList ParseResponse(IndexerResponse indexerResponse) if (indexerResponse.HttpResponse.StatusCode != HttpStatusCode.OK) { // Remove cookie cache - if (indexerResponse.HttpResponse.HasHttpRedirect && indexerResponse.HttpResponse.Headers["Location"] + if (indexerResponse.HttpResponse.HasHttpRedirect && indexerResponse.HttpResponse.RedirectUrl .ContainsIgnoreCase("login.php")) { CookiesUpdater(null, null);