No body logged for the HttpClient response under debug
- Dominant language
- C#
- Stars
- 3.2k
- Forks
- 894
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 23
Description
### Description
HttpClient does not log the response body under a debugger, because of an invalid check here https://github.com/dotnet/extensions/blob/dac7c3e6e0d2755614b53e05c7a886cbfe120d08/src/Libraries/Microsoft.Extensions.Http.Diagnostics/Logging/Internal/HttpResponseBodyReader.cs#L71
It assigns Timeout.InfiniteTimeSpan if debbuger attached and then cancel the read immediately.
### Reproduction Steps
Register a httpclient with logging enabled
` .AddExtendedHttpClientLogging(
options =>
{
options.LogBody = true;
options.RequestBodyContentTypes = LogBodyContentTypes;
options.ResponseBodyContentTypes = LogBodyContentTypes;
options.RequestPathParameterRedactionMode = HttpRouteParameterRedactionMode.None;
options.BodyReadTimeout = TimeSpan.FromSeconds(60);
});`
Run in debug mode.
### Expected behavior
Body is written for response under debugger
### Actual behavior
No body is written for response under debugger
### Regression?
_No response_
### Known Workarounds
_No response_
### Configuration
_No response_
### Other information
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.