mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
Fixed: (Cardigann) Use correct encoding for Auth and Download calls
This commit is contained in:
@@ -14,6 +14,7 @@ namespace NzbDrone.Common.Http
|
|||||||
public HttpAccept HttpAccept { get; set; }
|
public HttpAccept HttpAccept { get; set; }
|
||||||
public HttpUri BaseUrl { get; private set; }
|
public HttpUri BaseUrl { get; private set; }
|
||||||
public string ResourceUrl { get; set; }
|
public string ResourceUrl { get; set; }
|
||||||
|
public Encoding Encoding { get; set; }
|
||||||
public List<KeyValuePair<string, string>> QueryParams { get; private set; }
|
public List<KeyValuePair<string, string>> QueryParams { get; private set; }
|
||||||
public List<KeyValuePair<string, string>> SuffixQueryParams { get; private set; }
|
public List<KeyValuePair<string, string>> SuffixQueryParams { get; private set; }
|
||||||
public Dictionary<string, string> Segments { get; private set; }
|
public Dictionary<string, string> Segments { get; private set; }
|
||||||
@@ -37,6 +38,7 @@ namespace NzbDrone.Common.Http
|
|||||||
BaseUrl = new HttpUri(baseUrl);
|
BaseUrl = new HttpUri(baseUrl);
|
||||||
ResourceUrl = string.Empty;
|
ResourceUrl = string.Empty;
|
||||||
Method = HttpMethod.GET;
|
Method = HttpMethod.GET;
|
||||||
|
Encoding = Encoding.UTF8;
|
||||||
QueryParams = new List<KeyValuePair<string, string>>();
|
QueryParams = new List<KeyValuePair<string, string>>();
|
||||||
SuffixQueryParams = new List<KeyValuePair<string, string>>();
|
SuffixQueryParams = new List<KeyValuePair<string, string>>();
|
||||||
Segments = new Dictionary<string, string>();
|
Segments = new Dictionary<string, string>();
|
||||||
@@ -101,6 +103,7 @@ namespace NzbDrone.Common.Http
|
|||||||
protected virtual void Apply(HttpRequest request)
|
protected virtual void Apply(HttpRequest request)
|
||||||
{
|
{
|
||||||
request.Method = Method;
|
request.Method = Method;
|
||||||
|
request.Encoding = Encoding;
|
||||||
request.SuppressHttpError = SuppressHttpError;
|
request.SuppressHttpError = SuppressHttpError;
|
||||||
request.UseSimplifiedUserAgent = UseSimplifiedUserAgent;
|
request.UseSimplifiedUserAgent = UseSimplifiedUserAgent;
|
||||||
request.AllowAutoRedirect = AllowAutoRedirect;
|
request.AllowAutoRedirect = AllowAutoRedirect;
|
||||||
@@ -301,6 +304,13 @@ namespace NzbDrone.Common.Http
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual HttpRequestBuilder SetEncoding(Encoding encoding)
|
||||||
|
{
|
||||||
|
Encoding = encoding;
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public virtual HttpRequestBuilder AddPrefixQueryParam(string key, object value, bool replace = false)
|
public virtual HttpRequestBuilder AddPrefixQueryParam(string key, object value, bool replace = false)
|
||||||
{
|
{
|
||||||
if (replace)
|
if (replace)
|
||||||
|
@@ -187,6 +187,7 @@ namespace NzbDrone.Core.Indexers.Cardigann
|
|||||||
Method = HttpMethod.POST,
|
Method = HttpMethod.POST,
|
||||||
AllowAutoRedirect = true,
|
AllowAutoRedirect = true,
|
||||||
SuppressHttpError = true,
|
SuppressHttpError = true,
|
||||||
|
Encoding = _encoding
|
||||||
};
|
};
|
||||||
|
|
||||||
foreach (var pair in pairs)
|
foreach (var pair in pairs)
|
||||||
@@ -328,7 +329,8 @@ namespace NzbDrone.Core.Indexers.Cardigann
|
|||||||
var requestBuilder = new HttpRequestBuilder(captchaUrl.ToString())
|
var requestBuilder = new HttpRequestBuilder(captchaUrl.ToString())
|
||||||
{
|
{
|
||||||
LogResponseContent = true,
|
LogResponseContent = true,
|
||||||
Method = HttpMethod.GET
|
Method = HttpMethod.GET,
|
||||||
|
Encoding = _encoding
|
||||||
};
|
};
|
||||||
|
|
||||||
requestBuilder.Headers.Add("Referer", loginUrl);
|
requestBuilder.Headers.Add("Referer", loginUrl);
|
||||||
@@ -393,7 +395,8 @@ namespace NzbDrone.Core.Indexers.Cardigann
|
|||||||
{
|
{
|
||||||
LogResponseContent = true,
|
LogResponseContent = true,
|
||||||
Method = HttpMethod.POST,
|
Method = HttpMethod.POST,
|
||||||
AllowAutoRedirect = true
|
AllowAutoRedirect = true,
|
||||||
|
Encoding = _encoding
|
||||||
};
|
};
|
||||||
|
|
||||||
requestBuilder.Headers.Add("Referer", SiteLink);
|
requestBuilder.Headers.Add("Referer", SiteLink);
|
||||||
@@ -422,7 +425,8 @@ namespace NzbDrone.Core.Indexers.Cardigann
|
|||||||
LogResponseContent = true,
|
LogResponseContent = true,
|
||||||
Method = HttpMethod.POST,
|
Method = HttpMethod.POST,
|
||||||
AllowAutoRedirect = true,
|
AllowAutoRedirect = true,
|
||||||
SuppressHttpError = true
|
SuppressHttpError = true,
|
||||||
|
Encoding = _encoding
|
||||||
};
|
};
|
||||||
|
|
||||||
requestBuilder.SetCookies(Cookies);
|
requestBuilder.SetCookies(Cookies);
|
||||||
@@ -463,7 +467,8 @@ namespace NzbDrone.Core.Indexers.Cardigann
|
|||||||
{
|
{
|
||||||
LogResponseContent = true,
|
LogResponseContent = true,
|
||||||
Method = HttpMethod.GET,
|
Method = HttpMethod.GET,
|
||||||
SuppressHttpError = true
|
SuppressHttpError = true,
|
||||||
|
Encoding = _encoding
|
||||||
};
|
};
|
||||||
|
|
||||||
requestBuilder.Headers.Add("Referer", SiteLink);
|
requestBuilder.Headers.Add("Referer", SiteLink);
|
||||||
@@ -487,7 +492,8 @@ namespace NzbDrone.Core.Indexers.Cardigann
|
|||||||
{
|
{
|
||||||
LogResponseContent = true,
|
LogResponseContent = true,
|
||||||
Method = HttpMethod.GET,
|
Method = HttpMethod.GET,
|
||||||
SuppressHttpError = true
|
SuppressHttpError = true,
|
||||||
|
Encoding = _encoding
|
||||||
};
|
};
|
||||||
|
|
||||||
requestBuilder.Headers.Add("Referer", SiteLink);
|
requestBuilder.Headers.Add("Referer", SiteLink);
|
||||||
@@ -559,7 +565,8 @@ namespace NzbDrone.Core.Indexers.Cardigann
|
|||||||
var requestBuilder = new HttpRequestBuilder(loginUrl.AbsoluteUri)
|
var requestBuilder = new HttpRequestBuilder(loginUrl.AbsoluteUri)
|
||||||
{
|
{
|
||||||
LogResponseContent = true,
|
LogResponseContent = true,
|
||||||
Method = HttpMethod.GET
|
Method = HttpMethod.GET,
|
||||||
|
Encoding = _encoding
|
||||||
};
|
};
|
||||||
|
|
||||||
requestBuilder.Headers.Add("Referer", SiteLink);
|
requestBuilder.Headers.Add("Referer", SiteLink);
|
||||||
@@ -613,6 +620,7 @@ namespace NzbDrone.Core.Indexers.Cardigann
|
|||||||
var request = new HttpRequestBuilder(captchaUrl.ToString())
|
var request = new HttpRequestBuilder(captchaUrl.ToString())
|
||||||
.SetCookies(landingResult.GetCookies())
|
.SetCookies(landingResult.GetCookies())
|
||||||
.SetHeader("Referer", loginUrl.AbsoluteUri)
|
.SetHeader("Referer", loginUrl.AbsoluteUri)
|
||||||
|
.SetEncoding(_encoding)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
var response = await HttpClient.ExecuteProxiedAsync(request, Definition);
|
var response = await HttpClient.ExecuteProxiedAsync(request, Definition);
|
||||||
@@ -693,6 +701,7 @@ namespace NzbDrone.Core.Indexers.Cardigann
|
|||||||
|
|
||||||
var httpRequest = new HttpRequestBuilder(requestLinkStr)
|
var httpRequest = new HttpRequestBuilder(requestLinkStr)
|
||||||
.SetCookies(Cookies ?? new Dictionary<string, string>())
|
.SetCookies(Cookies ?? new Dictionary<string, string>())
|
||||||
|
.SetEncoding(_encoding)
|
||||||
.SetHeader("Referer", referer);
|
.SetHeader("Referer", referer);
|
||||||
|
|
||||||
httpRequest.Method = method;
|
httpRequest.Method = method;
|
||||||
@@ -731,6 +740,7 @@ namespace NzbDrone.Core.Indexers.Cardigann
|
|||||||
var request = new HttpRequestBuilder(link.ToString())
|
var request = new HttpRequestBuilder(link.ToString())
|
||||||
.SetCookies(Cookies ?? new Dictionary<string, string>())
|
.SetCookies(Cookies ?? new Dictionary<string, string>())
|
||||||
.SetHeaders(headers ?? new Dictionary<string, string>())
|
.SetHeaders(headers ?? new Dictionary<string, string>())
|
||||||
|
.SetEncoding(_encoding)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
request.AllowAutoRedirect = true;
|
request.AllowAutoRedirect = true;
|
||||||
@@ -779,6 +789,7 @@ namespace NzbDrone.Core.Indexers.Cardigann
|
|||||||
var hashDownloadRequest = new HttpRequestBuilder(torrentLink.AbsoluteUri)
|
var hashDownloadRequest = new HttpRequestBuilder(torrentLink.AbsoluteUri)
|
||||||
.SetCookies(Cookies ?? new Dictionary<string, string>())
|
.SetCookies(Cookies ?? new Dictionary<string, string>())
|
||||||
.SetHeaders(headers ?? new Dictionary<string, string>())
|
.SetHeaders(headers ?? new Dictionary<string, string>())
|
||||||
|
.SetEncoding(_encoding)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
hashDownloadRequest.Method = method;
|
hashDownloadRequest.Method = method;
|
||||||
@@ -819,6 +830,7 @@ namespace NzbDrone.Core.Indexers.Cardigann
|
|||||||
var testLinkRequest = new HttpRequestBuilder(torrentLink.ToString())
|
var testLinkRequest = new HttpRequestBuilder(torrentLink.ToString())
|
||||||
.SetCookies(Cookies ?? new Dictionary<string, string>())
|
.SetCookies(Cookies ?? new Dictionary<string, string>())
|
||||||
.SetHeaders(headers ?? new Dictionary<string, string>())
|
.SetHeaders(headers ?? new Dictionary<string, string>())
|
||||||
|
.SetEncoding(_encoding)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
response = await HttpClient.ExecuteProxiedAsync(testLinkRequest, Definition);
|
response = await HttpClient.ExecuteProxiedAsync(testLinkRequest, Definition);
|
||||||
@@ -837,6 +849,7 @@ namespace NzbDrone.Core.Indexers.Cardigann
|
|||||||
var selectorDownloadRequest = new HttpRequestBuilder(link.AbsoluteUri)
|
var selectorDownloadRequest = new HttpRequestBuilder(link.AbsoluteUri)
|
||||||
.SetCookies(Cookies ?? new Dictionary<string, string>())
|
.SetCookies(Cookies ?? new Dictionary<string, string>())
|
||||||
.SetHeaders(headers ?? new Dictionary<string, string>())
|
.SetHeaders(headers ?? new Dictionary<string, string>())
|
||||||
|
.SetEncoding(_encoding)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
selectorDownloadRequest.Method = method;
|
selectorDownloadRequest.Method = method;
|
||||||
@@ -856,6 +869,7 @@ namespace NzbDrone.Core.Indexers.Cardigann
|
|||||||
var downloadRequest = new HttpRequestBuilder(link.AbsoluteUri)
|
var downloadRequest = new HttpRequestBuilder(link.AbsoluteUri)
|
||||||
.SetCookies(Cookies ?? new Dictionary<string, string>())
|
.SetCookies(Cookies ?? new Dictionary<string, string>())
|
||||||
.SetHeaders(headers ?? new Dictionary<string, string>())
|
.SetHeaders(headers ?? new Dictionary<string, string>())
|
||||||
|
.SetEncoding(_encoding)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
downloadRequest.Method = method;
|
downloadRequest.Method = method;
|
||||||
@@ -1080,9 +1094,7 @@ namespace NzbDrone.Core.Indexers.Cardigann
|
|||||||
requestbuilder.SetHeaders(headers ?? new Dictionary<string, string>());
|
requestbuilder.SetHeaders(headers ?? new Dictionary<string, string>());
|
||||||
}
|
}
|
||||||
|
|
||||||
var request = new CardigannRequest(requestbuilder.Build(), variables, searchPath);
|
var request = new CardigannRequest(requestbuilder.SetEncoding(_encoding).Build(), variables, searchPath);
|
||||||
|
|
||||||
request.HttpRequest.Encoding = Encoding.GetEncoding(_definition.Encoding);
|
|
||||||
|
|
||||||
yield return request;
|
yield return request;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user