title: How can I tell if Connection: keep-alive is working?
body: <p>How can I tell if my HTTP connections are being reused when testing from a C# console application using HttpClient?</p>
  
  <p>I'm sending the correct headers (according to Fiddler) but the timings are identical whether or not I send the Connection: keep-alive header.</p>
  
  <p>I'm curious to know if it's always working (even without the header) or always <em>not</em> working.</p>
  
  <p>My code to set it up is as follows (and I'm reusing the same instance each time):</p>
  
  <pre><code>    if (String.IsNullOrEmpty(client.DefaultRequestHeaders.Connection.ToString()))
      {
          client.DefaultRequestHeaders.Add("Connection", "keep-alive");
      }
  </code></pre>
  
  <p>As an aside: I can't see an easier way to set this header directly - you can only Add() to it. That means if you call the method twice, you end up with "keep-alive, keep-alive" as the value!</p>