Repository: PowerShell/PowerShell
File: src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/Common/WebRequestPSCmdlet.Common.cs (C#)

Code before:
                // Strict-Transport-Security: max-age=2592000
                // Request-Context: appId=cid-v1:3548b0f5-7f75-492f-82bb-b6eb0e864e53
                // Content-Length: 6
                // Content-Type: text/plain
                // --- BODY
                // 200 OK
                StringBuilder debugBuilder = new("WebResponse Detail" + Environment.NewLine, 512);

                debugBuilder.AppendLine(DebugHeaderPrefix + "HEADERS");

                foreach (var headerSet in new HttpHeaders?[] { response.Headers, response.Content?.Headers })
                {
                    if (headerSet is null)
                    {
                        continue;
                    }

                    foreach (var header in headerSet)
                    {
                        debugBuilder.AppendLine($"{header.Key}: {string.Join(", ", header.Value)}");
                    }
                }

                if (response.Content is not null)
                {
                    debugBuilder.AppendLine(DebugHeaderPrefix + "BODY");

                    if (ContentHelper.IsTextBasedContentType(ContentHelper.GetContentType(response)))
                    {
                        debugBuilder.AppendLine(
                            response.Content.ReadAsStringAsync(_cancelToken.Token)
                            .GetAwaiter().GetResult());
                    }
                    else
                    {
                        string friendlyContentLength = ContentHelper.GetFriendlyContentLength(
                            response.Content?.Headers?.ContentLength);
                        debugBuilder.AppendLine($"[Binary content: {friendlyContentLength}]");
                    }
                }

                WriteDebug(debugBuilder.ToString().Trim());
            }
            catch (Exception ex)
            {
                // Just in case there are any edge cases we missed, we don't break workflows with an exception
                WriteVerbose($"Failed to Write WebResponse Debug Info: {ex} {ex.StackTrace}");
            }
        }

        private Uri PrepareUri(Uri uri)

Review comment (bug):
```suggestion
                    debugBuilder.Append(DebugHeaderPrefix).AppendLine("BODY");
```

Code after:
                // Content-Length: 6
                // Content-Type: text/plain
                // --- BODY
                // 200 OK
                StringBuilder debugBuilder = new("WebResponse Detail" + Environment.NewLine, 512);

                debugBuilder.Append(DebugHeaderPrefix).AppendLine("HEADERS");

                foreach (var headerSet in new HttpHeaders?[] { response.Headers, response.Content?.Headers })
                {
                    if (headerSet is null)
                    {
                        continue;
                    }

                    debugBuilder.AppendLine(headerSet.ToString());
                }

                if (response.Content is not null)
                {
                    debugBuilder.Append(DebugHeaderPrefix).AppendLine("BODY");

                    if (ContentHelper.IsTextBasedContentType(ContentHelper.GetContentType(response)))
                    {
                        debugBuilder.AppendLine(
                            response.Content.ReadAsStringAsync(_cancelToken.Token)
                            .GetAwaiter().GetResult());
                    }
                    else
                    {
                        string friendlyContentLength = ContentHelper.GetFriendlyContentLength(
                            response.Content?.Headers?.ContentLength);
                        debugBuilder.AppendLine($"[Binary content: {friendlyContentLength}]");
                    }
                }

                WriteDebug(debugBuilder.ToString().Trim());
            }
            catch (Exception ex)
            {
                // Just in case there are any edge cases we missed, we don't break workflows with an exception
                WriteVerbose($"Failed to Write WebResponse Debug Info: {ex} {ex.StackTrace}");
            }
        }

        private Uri PrepareUri(Uri uri)
        {
            uri = CheckProtocol(uri);

            // Before creating the web request,
            // preprocess Body if content is a dictionary and method is GET (set as query)