mirror of
https://github.com/Jackett/Jackett.git
synced 2025-12-22 14:16:59 +01:00
webclient: if response binary hexdump first 20 bytes #13532
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user