title: XMLHttpRequest add custom header
body: <p>I would like to pass access_token via HTTP header. </p>
  
  <pre><code>_xhr.setRequestHeader('x-customtoken', 'value');
  </code></pre>
  
  <p>When I want to get it on server it's value is null. I get it like this:</p>
  
  <pre><code>public final static String HEADER_SECURITY_TOKEN = "x-customtoken";
  // ..
  request.getHeader(HEADER_SECURITY_TOKEN)
  </code></pre>
  
  <p>Pass the token via header is the only solution for me. I can pass it like a request param, but I need to to it via HTTP-headers.</p>
  
  <pre><code>    xhr: function(options){
          var _xhr = new XMLHttpRequest(),
              _to_send = options.params;
  
          _xhr.open(options.type, options.url);
          _xhr.setRequestHeader('Content-Type', 'application/json');
          _xhr.setRequestHeader('x-customtoken', 'value');
          _xhr.responseType = 'json';
          _xhr.onload = function () {
              if (_xhr.status === 200) {
                  var _json = _xhr.response;
                  if (typeof _json == 'string')
                      _json = JSON.parse(_json);
                  options.success(_json);
              } else {
                  options.error(_xhr);
              }
          };
          try {
              _xhr.send(_to_send);
          } catch (e){
              options.error(_xhr);
          }
      }
  </code></pre>