using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace nksrv.Utils { public class LoggingHttpHandler(HttpMessageHandler innerHandler) : DelegatingHandler(innerHandler) { protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { Console.WriteLine("Request:"); Console.WriteLine(request.ToString()); if (request.Content != null) { Console.WriteLine(await request.Content.ReadAsStringAsync(cancellationToken)); } Console.WriteLine(); HttpResponseMessage response = await base.SendAsync(request, cancellationToken); Console.WriteLine("Response:"); Console.WriteLine(response.ToString()); if (response.Content != null) { Console.WriteLine(await response.Content.ReadAsStringAsync(cancellationToken)); } Console.WriteLine(); return response; } } }