protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { string apikey = HttpUtility.ParseQueryString(request.RequestUri.Query).Get("apikey"); var apiRequest = new WebApiUsageRequest(request, apikey); request.Content.ReadAsStringAsync().ContinueWith(t => { apiRequest.Content = t.Result; _repo.Add(apiRequest); }); return base.SendAsync(request, cancellationToken).ContinueWith( task => { var apiResponse = new WebApiUsageResponse(task.Result, apikey); apiResponse.Content = task.Result.Content.ReadAsStringAsync().Result; _repo.Add(apiResponse); return task.Result; } ); }
protected override Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { string apikey = HttpUtility.ParseQueryString(request.RequestUri.Query).Get("apikey"); var apiRequest = new WebApiUsageRequest(request, apikey); request.Content.ReadAsStringAsync().ContinueWith(t => { apiRequest.Content = t.Result; _repo.Add(apiRequest); }); return(base.SendAsync(request, cancellationToken).ContinueWith( task => { var apiResponse = new WebApiUsageResponse(task.Result, apikey); apiResponse.Content = task.Result.Content.ReadAsStringAsync().Result; _repo.Add(apiResponse); return task.Result; } )); }