title: C# HttpClient custom headers each request
body: <p>I've noticed that using HttpClient is <strong>NOT</strong> thread safe when modifying <em>HttpClient.DefaultRequestHeaders</em> but I want to make as many requests as possible.
  I need a custom header each request (2 other headers are always the same). Also the URL changes a bit </p>
  
  <ol>
  <li><a href="http://example.com/books/1234/readers/837" rel="nofollow noreferrer">http://example.com/books/1234/readers/837</a></li>
  <li><a href="http://example.com/books/854/readers/89" rel="nofollow noreferrer">http://example.com/books/854/readers/89</a></li>
  <li><a href="http://example.com/books/29432/readers/238" rel="nofollow noreferrer">http://example.com/books/29432/readers/238</a></li>
  <li>... so on</li>
  </ol>
  
  <p>Currently I'm creating a new HttpClient for every request but I feel like creating 10k+ HttpClients isn't the best choice here.</p>
  
  <p>I'd like to make one static HttpClient with 2 DefaultRequestHeaders and use this HttpClient for every request but also add one custom header.</p>
  
  <p>I want to make this as fast as possible so if you have something else I'll take it. </p>
  
  <pre><code>        Parallel.ForEach(Requests, Request =&gt;
          {
              var Client = new HttpClient();
              Client.DefaultRequestHeaders.Clear();
              Client.DefaultRequestHeaders.Add("Header1", "Value1");
              Client.DefaultRequestHeaders.Add("Header2", "Value2");
              Client.DefaultRequestHeaders.Add("Header3", "Value for exact this request");
  
              var response = Client.PutAsync(new Uri($"http://example.com/books/1234/readers/837"), null); //.Result (?)
              Client.Dispose();
          });
  </code></pre>