mirror of https://github.com/Jackett/Jackett
This reverts commit 1184a9285a
.
This commit is contained in:
parent
94feb875f7
commit
08c41c6daa
|
@ -114,9 +114,14 @@ namespace Jackett.Common.Utils.Clients
|
|||
var result = await Run(request);
|
||||
lastRequest = DateTime.Now;
|
||||
result.Request = request;
|
||||
WebClientStringResult stringResult = result;
|
||||
var stringResult = Mapper.Map<WebClientStringResult>(result);
|
||||
|
||||
logger.Debug(string.Format("WebClient({0}): Returning {1} => {2}", ClientType, result.Status, (result.IsRedirect ? result.RedirectingTo + " " : "") + (stringResult.ContentString ?? "<NULL>")));
|
||||
string decodedContent = null;
|
||||
if (result.ContentBytes != null)
|
||||
decodedContent = result.Encoding.GetString(result.ContentBytes);
|
||||
|
||||
stringResult.ContentString = decodedContent;
|
||||
logger.Debug(string.Format("WebClient({0}): Returning {1} => {2}", ClientType, result.Status, (result.IsRedirect ? result.RedirectingTo + " " : "") + (decodedContent == null ? "<NULL>" : decodedContent)));
|
||||
|
||||
if (stringResult.Headers.TryGetValue("server", out var server))
|
||||
{
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace Jackett.Common.Utils.Clients
|
|||
|
||||
public static implicit operator WebClientStringResult(WebClientByteResult br) => new WebClientStringResult()
|
||||
{
|
||||
ContentString = br.ContentBytes == null ? null : br.Encoding.GetString(br.ContentBytes),
|
||||
ContentString = br.Encoding.GetString(br.ContentBytes),
|
||||
Cookies = br.Cookies,
|
||||
Encoding = br.Encoding,
|
||||
Headers = br.Headers,
|
||||
|
|
|
@ -73,6 +73,23 @@ namespace Jackett.Server
|
|||
// TODO: fix deprecation warning (remove #pragma to see the build warning)
|
||||
Mapper.Initialize(cfg =>
|
||||
{
|
||||
cfg.CreateMap<WebClientByteResult, WebClientStringResult>().ForMember(x => x.ContentString, opt => opt.Ignore()).AfterMap((be, str) =>
|
||||
{
|
||||
var encoding = be.Request.Encoding ?? Encoding.UTF8;
|
||||
str.ContentString = encoding.GetString(be.ContentBytes);
|
||||
});
|
||||
|
||||
cfg.CreateMap<WebClientStringResult, WebClientByteResult>().ForMember(x => x.ContentBytes, opt => opt.Ignore()).AfterMap((str, be) =>
|
||||
{
|
||||
if (!string.IsNullOrEmpty(str.ContentString))
|
||||
{
|
||||
var encoding = str.Request.Encoding ?? Encoding.UTF8;
|
||||
be.ContentBytes = encoding.GetBytes(str.ContentString);
|
||||
}
|
||||
});
|
||||
|
||||
cfg.CreateMap<WebClientStringResult, WebClientStringResult>();
|
||||
cfg.CreateMap<WebClientByteResult, WebClientByteResult>();
|
||||
cfg.CreateMap<ReleaseInfo, ReleaseInfo>();
|
||||
|
||||
cfg.CreateMap<ReleaseInfo, TrackerCacheResult>().AfterMap((r, t) =>
|
||||
|
|
Loading…
Reference in New Issue