Skip to content

Commit f958c28

Browse files
committed
fix: Log if content body was disposed before logger could access it.
1 parent 31c522b commit f958c28

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

tools/Custom/HttpMessageLogFormatter.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,14 @@ public static async Task<string> GetHttpRequestLogAsync(HttpRequestMessage reque
7373
string body = string.Empty;
7474
try
7575
{
76-
body = (requestClone.Content == null) ? string.Empty : FormatString(await requestClone.Content.ReadAsStringAsync());
76+
if (requestClone.Content != null)
77+
{
78+
body = FormatString(await requestClone.Content.ReadAsStringAsync());
79+
}
80+
else if (requestClone.Content == null && request.Content != null)
81+
{
82+
body = "Skipped: Content body was disposed before the logger could access it.";
83+
}
7784
}
7885
catch { }
7986

0 commit comments

Comments
 (0)