title: IE sending wrong content type on redirect using XMLHttpRequest
body: <p>This is my first time working with XMLHttpRequest directly. Hopefully someone can give me a hint </p>
  
  <p>Scenario:
  I'm trying to upload a file to my server using XMLHttpRequest.To do this I:</p>
  
  <p>POST a form ( multipart ) to my server using XMLHttpRequest. This POST works as expected; file is uploaded  and no errors displayed. </p>
  
  <p>Then  my server responds with a redirect. I can see the Internet Explorer executing the redirect with a GET but the content type remained 'multipart'(form the first request ). This causes my server to crash. Content type is set to multipart but no actual information to parse is sent.</p>
  
  <p>The exact same code works perfectly in Chrome and Firefox, but not with IE.</p>
  
  <p>HTML form</p>
  
  <pre><code>&lt;form action="my path" enctype="multipart/form-data" method="post"&gt;
    &lt;input  name="import[my_file]" type="file"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>ROR Code is pretty straight fw</p>
  
  <pre><code>class MyController &lt; ApplicationController
  
    def my_action
      file = params[:import][:my_file]
      ...
      redirect_to :action =&gt; :other_action
    end
  
    def other_action
      render :text =&gt; 'Just an ilustration'
    end
  end
  </code></pre>
  
  <p>Javascript Code</p>
  
  <pre><code>var form = $('&lt;The form containing the file input&gt;')[0];
  var formData = new FormData(form);
  var url = $(this).attr('action');
  
  var request = new XMLHttpRequest();
  var response = request.open('POST', url, true);
  
  request.onreadystatechange = function() {
    if (request.readyState == XMLHttpRequest.DONE) {
      // Code when it is done
    }
  }
  
  request.send(formData);
  return false;
  </code></pre>
  
  <p>Here both requests: POST to upload file and GET for redirect:</p>
  
  <p><a href="https://i.stack.imgur.com/W4KME.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/W4KME.png" alt="enter image description here"></a></p>
  
  <p>These are the POST headers, request and response:</p>
  
  <p><a href="https://i.stack.imgur.com/t7gDg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/t7gDg.png" alt="Post Request"></a></p>
  
  <p><a href="https://i.stack.imgur.com/iwKuy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iwKuy.png" alt="Post Response"></a></p>
  
  <p>These are GET headers, request and response. You can see how the Content type is set to multipart-formdata, which is incorrect. </p>
  
  <p><a href="https://i.stack.imgur.com/x1WBb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/x1WBb.png" alt="Get Request"></a>
  <a href="https://i.stack.imgur.com/qssNu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qssNu.png" alt="Get Response"></a></p>
  
  <p>In order to make sure the redirect along with XMLHttpRequest are somehow the "cause" of this problem, I got rid of the XMLHttpRequest code and let the form behave normally. The GET call for the redirect had the correct content type ( text/html ). It worked correctly. </p>
  
  <p>Any idea what I could do to make IE use the correct content type in the GET request for the redirect after the POST, using the XMLHttpRequest?</p>
  
  <p>( Sorry for the ultra long post ) </p>