PATCH Async requests with Windows.Web.Http.HttpClient class

I found how to do a “custom” PATCH request with the previous System.Net.Http.HttpClient class here, and then fiddled with until I made it work in the Windows.Web.Http.HttpClient class, like so: public async Task<HttpResponseMessage> PatchAsync(HttpClient client, Uri requestUri, IHttpContent iContent) { var method = new HttpMethod(“PATCH”); var request = new HttpRequestMessage(method, requestUri) { Content = iContent … Read more

Why use HttpClient for Synchronous Connection

but what i am doing is purely synchronous You could use HttpClient for synchronous requests just fine: using (var client = new HttpClient()) { var response = client.GetAsync(“http://google.com”).Result; if (response.IsSuccessStatusCode) { var responseContent = response.Content; // by calling .Result you are synchronously reading the result string responseString = responseContent.ReadAsStringAsync().Result; Console.WriteLine(responseString); } } As far as … Read more

Re-Send HttpRequestMessage – Exception

I wrote the following extension method to clone the request. public static HttpRequestMessage Clone(this HttpRequestMessage req) { HttpRequestMessage clone = new HttpRequestMessage(req.Method, req.RequestUri); clone.Content = req.Content; clone.Version = req.Version; foreach (KeyValuePair<string, object> prop in req.Properties) { clone.Properties.Add(prop); } foreach (KeyValuePair<string, IEnumerable<string>> header in req.Headers) { clone.Headers.TryAddWithoutValidation(header.Key, header.Value); } return clone; }

Is async HttpClient from .Net 4.5 a bad choice for intensive load applications?

Besides the tests mentioned in the question, I recently created some new ones involving much fewer HTTP calls (5000 compared to 1 million previously) but on requests that took much longer to execute (500 milliseconds compared to around 1 millisecond previously). Both tester applications, the synchronously multithreaded one (based on HttpWebRequest) and asynchronous I/O one … Read more