mirror of
https://github.com/Prowlarr/Prowlarr
synced 2026-01-02 22:06:28 +01:00
Fixed: Cardigann redirect handling fails for relative location headers
This commit is contained in:
parent
fa05dbc642
commit
d9e211472b
4 changed files with 18 additions and 4 deletions
|
|
@ -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<string>();
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ public IList<ReleaseInfo> 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);
|
||||
|
|
|
|||
|
|
@ -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<HttpResponse> HandleRequest(RequestBlock request, Dictionary<string, object> variables = null, string referer = null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public IList<ReleaseInfo> 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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue