mirror of
https://github.com/Prowlarr/Prowlarr
synced 2025-12-15 21:14:32 +01:00
parent
74663ea077
commit
64c1e1fa54
2 changed files with 18 additions and 3 deletions
|
|
@ -75,7 +75,7 @@ public virtual async Task<HttpResponse> ExecuteAsync(HttpRequest request)
|
|||
|
||||
do
|
||||
{
|
||||
request.Url += new HttpUri(response.Headers.GetSingleValue("Location"));
|
||||
request.Url = new HttpUri(response.RedirectUrl);
|
||||
autoRedirectChain.Add(request.Url.ToString());
|
||||
|
||||
_logger.Trace("Redirected to {0}", request.Url);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace NzbDrone.Common.Http
|
|||
{
|
||||
public class HttpResponse
|
||||
{
|
||||
private static readonly Regex RegexSetCookie = new Regex("^(.*?)=(.*?)(?:;|$)", RegexOptions.Compiled);
|
||||
private static readonly Regex RegexRefresh = new Regex("^(.*?url)=(.*?)(?:;|$)", RegexOptions.Compiled);
|
||||
|
||||
public HttpResponse(HttpRequest request, HttpHeader headers, CookieCollection cookies, byte[] binaryData, long elapsedTime = 0, HttpStatusCode statusCode = HttpStatusCode.OK)
|
||||
{
|
||||
|
|
@ -67,7 +67,8 @@ public string Content
|
|||
StatusCode == HttpStatusCode.MovedPermanently ||
|
||||
StatusCode == HttpStatusCode.RedirectMethod ||
|
||||
StatusCode == HttpStatusCode.TemporaryRedirect ||
|
||||
StatusCode == HttpStatusCode.Found;
|
||||
StatusCode == HttpStatusCode.Found ||
|
||||
Headers.ContainsKey("Refresh");
|
||||
|
||||
public string RedirectUrl
|
||||
{
|
||||
|
|
@ -76,6 +77,20 @@ public string RedirectUrl
|
|||
var newUrl = Headers["Location"];
|
||||
if (newUrl == null)
|
||||
{
|
||||
newUrl = Headers["Refresh"];
|
||||
|
||||
if (newUrl == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
var match = RegexRefresh.Match(newUrl);
|
||||
|
||||
if (match.Success)
|
||||
{
|
||||
return (Request.Url += new HttpUri(match.Groups[2].Value)).FullUri;
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue