1
votes

I'm trying to make a HEAD request to Google.com.

This is my code:

using (var client = new HttpClient()) 
{
    var m = new HttpRequestMessage(HttpMethod.Head, "http://google.com");

    var resp = await client.SendAsync(m);
    return true;
}

When I execute this code I get the following exception:

System.Net.WebException: The request requires buffering data to succeed.
at System.Net.HttpWebRequest.Redirect (System.Net.WebAsyncResult result, HttpStatusCode code, System.Net.WebResponse response) [0x00000] in :0
at System.Net.HttpWebRequest.CheckFinalStatus (System.Net.WebAsyncResult result) [0x00000] in :0
at System.Net.HttpWebRequest.SetResponseData (System.Net.WebConnectionData data) [0x00000] in :0

I can't understand why... Google accept Head requests because using Postman I get a 200 OK code

Can you help me?

Are you sending multiple requests concurrently?Yuval Itzchakov
No, just one to googleuser3471528
I copy-pasted your code and it works fine, i get a 200 OK back.Yuval Itzchakov
I tryed on a Console project and you're right. However th eproblem persists on Monodroid (Xamarin.Android). I'm sorry, I did not specify that I'm working on a Xamarin project. I solved using WebRequestuser3471528