title: Adding a HTTP header to the Angular HttpClient doesn't send the header, why?
body: <p>Here is my code: </p>
  
  <pre class="lang-js prettyprint-override"><code>import { HttpClient, HttpErrorResponse, HttpHeaders } from '@angular/common/http';
  </code></pre>
  
  <hr>
  
  <pre class="lang-js prettyprint-override"><code>logIn(username: string, password: string) {
      const url = 'http://server.com/index.php';
      const body = JSON.stringify({username: username,
                                   password: password});
      const headers = new HttpHeaders();
      headers.set('Content-Type', 'application/json; charset=utf-8');
      this.http.post(url, body, {headers: headers}).subscribe(
          (data) =&gt; {
              console.log(data);
          },
          (err: HttpErrorResponse) =&gt; {
              if (err.error instanceof Error) {
                  console.log('Client-side error occured.');
              } else {
                  console.log('Server-side error occured.');
              }
          }
      );
  }
  </code></pre>
  
  <p>and here the network debug:</p>
  
  <pre><code>Request Method:POST
  Status Code:200 OK
  Accept:application/json, text/plain, */*
  Accept-Encoding:gzip, deflate
  Accept-Language:en-US,en;q=0.8
  Cache-Control:no-cache
  Connection:keep-alive
  Content-Length:46
  Content-Type:text/plain
  </code></pre>
  
  <p>and Data are stored in 'Request Payload' but in my server doesn't received the POST values:</p>
  
  <pre><code>print_r($_POST);
  Array
  (
  )
  </code></pre>
  
  <p>I believe the error comes from the header not set during the POST, what did I do wrong?</p>