Created
July 11, 2012 14:16
-
-
Save jritsema/3090623 to your computer and use it in GitHub Desktop.
LoggingMessageHandler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LoggingMessageHandler : DelegatingHandler { | |
public LoggingMessageHandler(HttpMessageHandler innerHandler) : base(innerHandler) {} | |
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { | |
Console.WriteLine(request.ToString()); | |
var task = base.SendAsync(request, cancellationToken); | |
task.ContinueWith(t => { | |
if (!t.IsFaulted) | |
Console.WriteLine(t.Result.ToString()); | |
}); | |
return task; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment