title: Firefox is parsing empty response payload
body: <p>We're making an XHR request with the following headers (I've simplified a bit):</p>
  <pre><code>POST http://localhost:9001/login
  
  Host: localhost:9001
  User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0
  Accept: application/json, text/plain, */*
  Content-Type: application/json;charset=utf-8
  Content-Length: 67
  </code></pre>
  <p>Then our server responds like this (again simplified):</p>
  <pre><code>Status code: 200 OK
  
  Cache-Control: no-cache, no-store
  Connection: close
  Content-Length: 0
  Date: Mon, 27 Feb 2017 17:19:53 GMT
  Server: WildFly/9
  Set-Cookie: JSESSIONID=123; path=/
  </code></pre>
  <p>There's no payload in the response. Note the <code>Content-Length: 0</code>. But Firefox still tries to parse it as XML. And outputs the following error to the console:</p>
  <pre><code>XML Parsing Error: no root element found 
  Location: http://localhost:9001/login 
  Line Number 1, Column 1
  </code></pre>
  <p>Note, the server doesn't send a <code>content-type</code> header. And according to <a href="https://www.rfc-editor.org/rfc/rfc7231#section-3.1.1.5" rel="nofollow noreferrer">RFC 7231</a> it only has to send a <code>content-type</code> header when there is actual content.</p>
  <p>So is this a bug in Firefox or is my research faulty?</p>
  <p><strong>Reproducing it yourself</strong></p>
  <p>I've written a small server and client to reproduce the problem.</p>
  <p><strong><code>server.js</code></strong> (start with <code>node ./server.js</code>):</p>
  <pre><code>const fs = require('fs'), http = require('http');
  const server = http.createServer(function (request, response) {
      if (request.method === 'POST') {
          // send empty response
          response.end();
          return;
      }
  
      // send file content
      fs.readFile('.' + request.url, function (error, content) {
          response.writeHead(200, { 'Content-Type': request.url === '/index.html' ? 'text/html' : 'text/javascript' });
          response.end(content);
      });
  }).listen(8080);
  </code></pre>
  <p><strong><code>index.html</code></strong></p>
  <pre><code>&lt;script src=&quot;client.js&quot;&gt;&lt;/script&gt;
  </code></pre>
  <p><strong><code>client.js</code></strong></p>
  <pre><code>var xhr = new XMLHttpRequest();
  xhr.open('POST', 'http://localhost:8080/login');
  xhr.send();
  </code></pre>
  <p>When opening the URL <a href="http://localhost:8080/index.html" rel="nofollow noreferrer">http://localhost:8080/index.html</a> in Firefox, there will be an error in the JavaScript console.</p>
  <p>Firefox Version 51.0.1</p>