mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
* Rename avalonia & wpf samples * Rename rest of samples * fix sample readme * Fix compat util tests * rename / move all src projects * remove package lock files and move libC# again * Add rust lib and cargo workspace * Replace locksmith lib with new filelocksmith-rs library * Deprecated type * fix setup compile * Use thiserror for error handling * Rename some enums and formatting * Add missing SHA256 * wip c++ library * cpp wip * alphabetize readme * Try to get build working again * Fix some conditionally compiled bits * cross config should be in workspace root * Fix PathHelper for new rust target dir * Missed one old path to velopack.csproj * remove obsolete coverage code * testawareapp.exe no longer exists
45 lines
1.5 KiB
C#
45 lines
1.5 KiB
C#
namespace UnoSample.Services.Endpoints;
|
|
|
|
internal class DebugHttpHandler : DelegatingHandler
|
|
{
|
|
private readonly ILogger _logger;
|
|
|
|
public DebugHttpHandler(ILogger<DebugHttpHandler> logger, HttpMessageHandler? innerHandler = null)
|
|
: base(innerHandler ?? new HttpClientHandler())
|
|
{
|
|
_logger = logger;
|
|
}
|
|
|
|
protected async override Task<HttpResponseMessage> SendAsync(
|
|
HttpRequestMessage request,
|
|
CancellationToken cancellationToken)
|
|
{
|
|
var response = await base.SendAsync(request, cancellationToken);
|
|
#if DEBUG
|
|
if (!response.IsSuccessStatusCode)
|
|
{
|
|
_logger.LogDebugMessage("Unsuccessful API Call");
|
|
if (request.RequestUri is not null)
|
|
{
|
|
_logger.LogDebugMessage($"{request.RequestUri} ({request.Method})");
|
|
}
|
|
|
|
foreach ((var key, var values) in request.Headers.ToDictionary(x => x.Key, x => string.Join(", ", x.Value)))
|
|
{
|
|
_logger.LogDebugMessage($"{key}: {values}");
|
|
}
|
|
|
|
var content = request.Content is not null ? await request.Content.ReadAsStringAsync() : null;
|
|
if (!string.IsNullOrEmpty(content))
|
|
{
|
|
_logger.LogDebugMessage(content);
|
|
}
|
|
|
|
// Uncomment to automatically break when an API call fails while debugging
|
|
// System.Diagnostics.Debugger.Break();
|
|
}
|
|
#endif
|
|
return response;
|
|
}
|
|
}
|