title: xmlHttpRequest does not close connections
body: <p>I make an AJAX request and depending on the answer I will refresh the current page, code is like this:</p>
  
  <pre><code>var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
  if (xhttp.readyState == 4 &amp;&amp; xhttp.status == 200) {
    var res = xhttp.responseText;
    if (res.length &gt; 0) {
        window.location = res;
    }
  }
  }
  xhttp.open("POST", "getlink.php", true);
  xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  xhttp.send('id='+id);
  </code></pre>
  
  <p>However I noticed that connections are not closed on the server. When running this command:</p>
  
  <pre><code>netstat -anl | grep 80 | awk '/^tcp/ {t[$NF]++}END{for(state in t){print state, t[state]} }'
  </code></pre>
  
  <p>I see a lot of connections in TIME_WAIT state:</p>
  
  <pre><code>LAST_ACK 4
  LISTEN 2
  SYN_RECV 2
  ESTABLISHED 1421
  FIN_WAIT1 9
  FIN_WAIT2 17
  TIME_WAIT 2250
  </code></pre>
  
  <p>It would seem that xmlHttpRequest does not close connections creating a lot of problems on the server. </p>