title: HTTP request with custom headers returns 400 error (invalid HTTP status code)
body: <p>I am trying to make HTTP POST request with custom headers using AngularJS (in my case API_VERSION and Distributor). So my code looks like this:</p>
  
  <pre><code>$http({
      method: "POST",
      url: url,
      data: {
          "Email": email,
          "Password": password,
          "DistributorId": 2
      },
      headers: {
          "API_VERSION": 4,
          "Distributor": 2
      }
  }).then(function(response) {
      console.log("success");
  }, function(response) {
      console.log("error");
  });
  </code></pre>
  
  <p>I tried to run this code in Chrome and got next error:</p>
  
  <pre><code>OPTIONS &lt;url&gt;
  XMLHttpRequest cannot load &lt;url&gt;. Invalid HTTP status code 400
  </code></pre>
  
  <p>As far as I understand browser generates preflight request with Origin, Access-Control-Request-Headers and Access-Control-Request-Method headers. Server should then respond with the following headers:</p>
  
  <pre><code>Access-Control-Allow-Origin: *
  Access-Control-Allow-Methods: POST
  Access-Control-Allow-Headers: API_VERSION, Distributor
  </code></pre>
  
  <p>But in my case API_VERSION and Distributor headers are not in Access-Control-Allow-Headers list. This means that I can't make HTTP POST request with this headers, as I understand.</p>
  
  <p>This behavior is observed both in Chrome and Firefox, but works fine in Safari. I have tested this webservice with Advanced REST Client and all works just fine too.</p>
  
  <p>What is the reason of this behavior and how can I get this to work?</p>
  
  <p>Thanks in advance!</p>
  
  <p>UPDATE: It's very strange, but when I removed all custom headers I still get the same 400 error. And Safari tells me that:</p>
  
  <pre><code>Failed to load resource: Request header field Content-Type is not allowed by Access-Control-Allow-Headers.
  </code></pre>
  
  <p>Indeed, Content-Type header is not in the Access-Control-Allow-Headers list as Chrome shows me.</p>