Created
November 7, 2012 02:42
-
-
Save darrelmiller/4029298 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 RequestPreprocessor : DelegatingHandler { | |
public RequestPreprocessor(HttpMessageHandler handler) { | |
this.InnerHandler = handler; | |
} | |
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) | |
{ | |
request.Content.LoadIntoBufferAsync().RunSynchronously(); | |
// Do your stuff! | |
return base.SendAsync(request, cancellationToken); | |
} | |
} | |
var client = new HttpClient(new RequestPreprocessor(new HttpClientHandler())); | |
client.PostAsync(new Uri("http://example.org"), new StringContent("Hello World")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment