diff --git a/src/Jackett.Common/Utils/Clients/WebClient.cs b/src/Jackett.Common/Utils/Clients/WebClient.cs index f8ca24bb9..e8323542a 100644 --- a/src/Jackett.Common/Utils/Clients/WebClient.cs +++ b/src/Jackett.Common/Utils/Clients/WebClient.cs @@ -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 = " "; + 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;