title: How to use HttpClient.PostAsync asynchronous when the URL responds after an artificial timeout?
body: <p><strong>How can <a href="https://msdn.microsoft.com/en-us/library/hh138242(v=vs.118).aspx" rel="nofollow noreferrer">HttpClient.PostAsync</a> be used to post HTTP requests to URLs which have an artificial time for sending back a response.</strong></p>
  
  <p>Please note the URL and the parameter <strong>sleep=30</strong> which is used to introduce an artificial delay of 30 seconds before sending back an HTTP response.</p>
  
  <pre><code>        Console.WriteLine("Start time : " + DateTime.Now);
  
          for (int i = 1; i &lt;= 10; i++)
          { 
              using (var client = new HttpClient())
              {
                  client.BaseAddress = new Uri(@"http://fake-response.appspot.com/api/?data={Hello World}&amp;sleep=30");
                  //client.BaseAddress = new Uri(@"http://fake-response.appspot.com/api/?data={Hello World}&amp;status=200");
  
                  client.Timeout = new TimeSpan(0, 0, 60);
  
                  var parameters = new Dictionary&lt;string, string&gt;();
                  parameters["ContentType"] = "text/plain;charset=UTF-8";
  
                  //Create Task to POST to the URL
                  client.DefaultRequestHeaders.ExpectContinue = true;
                  var response = await client.PostAsync(client.BaseAddress, new FormUrlEncodedContent(parameters));
  
                  Task&lt;bool&gt; b1 = ProcessURLAsync(response, 1, 5, 2);
              }
          }
  
          Console.WriteLine("End time : " + DateTime.Now);
  </code></pre>
  
  <p>What needs to be done is that async HTTP Posts need to be made in a loop and should not be dependent on the timeout specified in the URL.
  However, the PostAsync times out before a response is received. </p>
  
  <p>Please check the time needed for POSTing the 2 different URLs in a loop of 10 async POSTs</p>
  
  <p>I checked <a href="https://stackoverflow.com/questions/33494609/httpclient-defaultrequestheaders-expectcontinue-what-purpose-does-expectcontinu">HttpClient.DefaultRequestHeaders.ExpectContinue</a> , but I do not think this might help in this use case.</p>