Include response body in HttpRequestException for transport client errors (#1193)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
This commit is contained in:
Copilot 2026-01-29 17:23:21 -05:00 • committed by GitHub
commit 7c85ac6706
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -499,7 +499,7 @@ internal sealed partial class ClientOAuthProvider : McpHttpClient
};
using var httpResponse = await _httpClient.SendAsync(request, cancellationToken).ConfigureAwait(false);
httpResponse.EnsureSuccessStatusCode();
await httpResponse.EnsureSuccessStatusCodeWithResponseBodyAsync(cancellationToken).ConfigureAwait(false);
var tokens = await HandleSuccessfulTokenResponseAsync(httpResponse, cancellationToken).ConfigureAwait(false);
LogOAuthAuthorizationCompleted();
@ -544,7 +544,7 @@ internal sealed partial class ClientOAuthProvider : McpHttpClient
using var httpResponse = await _httpClient.GetAsync(metadataUrl, cancellationToken).ConfigureAwait(false);
if (requireSuccess)
{
httpResponse.EnsureSuccessStatusCode();
await httpResponse.EnsureSuccessStatusCodeWithResponseBodyAsync(cancellationToken).ConfigureAwait(false);
}
else if (!httpResponse.IsSuccessStatusCode)
{