Skip to content

Commit 2fd6d80

Browse files
committed
Merge dev
1 parent bf5b90a commit 2fd6d80

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

tools/Custom/HttpMessageLogFormatter.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ public static string GetHttpRequestLog(HttpRequestMessage request)
2121
{
2222
if (request == null) return string.Empty;
2323

24-
string body = (request.Content == null) ? string.Empty : FormatString(request.Content.ReadAsStringAsync().Result);
24+
string body = string.Empty;
25+
try
26+
{
27+
body = FormatString(request.Content.ReadAsStringAsync().Result);
28+
}
29+
catch { }
2530

2631
StringBuilder stringBuilder = new StringBuilder();
2732
stringBuilder.AppendLine($"============================ HTTP REQUEST ============================{Environment.NewLine}");
@@ -36,7 +41,12 @@ public static string GetHttpResponseLog(HttpResponseMessage response)
3641
{
3742
if (response == null) return string.Empty;
3843

39-
string body = (response.Content == null) ? string.Empty : FormatString(response.Content.ReadAsStringAsync().Result);
44+
string body = string.Empty;
45+
try
46+
{
47+
body = FormatString(response.Content.ReadAsStringAsync().Result);
48+
}
49+
catch { }
4050

4151
StringBuilder stringBuilder = new StringBuilder();
4252
stringBuilder.AppendLine($"============================ HTTP RESPONSE ============================{Environment.NewLine}");

0 commit comments

Comments
 (0)