mirror of
https://github.com/EpinelPS/EpinelPS.git
synced 2025-12-16 08:54:47 +01:00
29 lines
1009 B
C#
29 lines
1009 B
C#
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;
|
|
}
|
|
}
|
|
}
|