mirror of
https://github.com/EpinelPS/EpinelPS.git
synced 2025-12-14 16:04:36 +01:00
35 lines
1.1 KiB
C#
35 lines
1.1 KiB
C#
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<HttpResponseMessage> 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;
|
|
}
|
|
}
|
|
}
|