title: XMLHttpRequest setRequestHeader for each request
body: <p>The following code automatically sets <code>Authorization request header</code> for all jQuery Ajax requests:</p>
  
  <pre><code>$.ajaxSetup({
      beforeSend: function(xhr) {
          xhr.setRequestHeader('Authorization', 'Bearer ' + jwtoken);
      }
  });
  </code></pre>
  
  <p>I want something like above for all <code>XMLHttpRequest</code> objects created manually. More exactly the below request hasn't set <code>Authorization header</code>. </p>
  
  <pre><code>var xhr = new XMLHttpRequest();
  xhr.file = $('myfile')[0].files[0];
  var fd = new FormData();
  fd.append('fileId', fileId);
  xhr.open('post','my-rote', true)
  xhr.send(fd);  
  </code></pre>
  
  <p>I don't want to use <code>xhr.setRequestHeader('Authorization', 'Bearer ' + jwtoken);</code> beacuse when I create <code>XMLHttpRequest</code> objects the variable <code>jwtoken</code> is already deleted.  </p>