-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLoggingHandler.cs
38 lines (33 loc) · 1.13 KB
/
LoggingHandler.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System.Diagnostics;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
namespace TAC_Grabber
{
public class LoggingHandler : DelegatingHandler
{
public LoggingHandler(HttpMessageHandler innerHandler)
: base(innerHandler)
{
}
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
Debug.WriteLine("Request:");
Debug.WriteLine(request.ToString());
if (request.Content != null)
{
Debug.WriteLine(await request.Content.ReadAsStringAsync());
}
Debug.WriteLine(string.Empty);
HttpResponseMessage response = await base.SendAsync(request, cancellationToken);
Debug.WriteLine("Response:");
Debug.WriteLine(response.ToString());
if (response.Content != null)
{
Debug.WriteLine(await response.Content.ReadAsStringAsync());
}
Debug.WriteLine(string.Empty);
return response;
}
}
}