mirror of https://github.com/Jackett/Jackett
webclient: if response binary hexdump first 20 bytes #13532
This commit is contained in:
parent
78a36a3a9a
commit
927431fba2
|
@ -191,6 +191,7 @@ namespace Jackett.Common.Utils.Clients
|
|||
{
|
||||
var body = "";
|
||||
var bodySize = 0;
|
||||
var isBinary = false;
|
||||
if (result.ContentBytes != null && result.ContentBytes.Length > 0)
|
||||
{
|
||||
bodySize = result.ContentBytes.Length;
|
||||
|
@ -198,11 +199,22 @@ namespace Jackett.Common.Utils.Clients
|
|||
if (contentString.StartsWith("<") || contentString.StartsWith("{") || contentString.StartsWith("["))
|
||||
body = "\n" + contentString;
|
||||
else
|
||||
{
|
||||
body = " <BINARY>";
|
||||
isBinary = true;
|
||||
}
|
||||
}
|
||||
logger.Debug($@"WebClient({ClientType}): Returning {result.Status} => {
|
||||
(result.IsRedirect ? result.RedirectingTo + " " : "")
|
||||
}{bodySize} bytes{body}");
|
||||
if (isBinary)
|
||||
{
|
||||
// show the first 20 bytes in a hex dump
|
||||
var contentString = result.ContentString.Trim();
|
||||
contentString = contentString.Length <= 20 ? contentString : contentString.Substring(0, 20);
|
||||
var HexData = string.Join("", contentString.Select(c => c + "(" + ((int)c).ToString("X2") + ")"));
|
||||
logger.Debug(string.Format("WebClient({0}): HexDump20: {1}", ClientType, HexData));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
Loading…
Reference in New Issue