title: nsIUploadChannel - The connection was reset
body: <p>I try to save post data to local file. But if i do that, in browser i see</p>
  
  <blockquote>
    <p>The connection was reset
              The connection to the server was reset while the page was
    loading.   The site could be temporarily unavailable or too busy. Try
    again in a few
        moments.   If you are unable to load any pages, check your
    computer's network
        connection.   If your computer or network is protected by a
    firewall or proxy, make sure
        that Firefox is permitted to access the Web.</p>
  </blockquote>
  
  <p>There is my code:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;?xml-stylesheet href="chrome://global/skin/" type="text/css"?&gt;
  &lt;window id="yourwindow" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"&gt;
  
   &lt;script&gt;
  &lt;![CDATA[
  var MIKI =
  {
   observe: function(subject, topic, data) 
   {
    if (topic == "http-on-modify-request") 
    {
     var httpChannel = subject.QueryInterface(Components.interfaces.nsIHttpChannel);
     if(httpChannel.requestMethod == "POST"){
     var uploadChannel = httpChannel.QueryInterface(Components.interfaces.nsIUploadChannel);
     var uploadChannelStream = uploadChannel.uploadStream;
     uploadChannelStream.QueryInterface(Components.interfaces.nsISeekableStream);                 
     uploadChannelStream.seek(0,0);                               
     var stream = Components.classes['@mozilla.org/scriptableinputstream;1'].createInstance(Components.interfaces.nsIScriptableInputStream);
     stream.init(uploadChannelStream);
     var data = stream.read(stream.available());
     data = data.split(/\r\n\r\n/).slice(1).join('\r\n\r\n');
     var buffer = httpChannel.URI.spec + " " + data+ "\n";
     if(data != '') fos.write(buffer, buffer.length);
    }
   }
  } 
  };
  var file = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("Desk", Components.interfaces.nsIFile);
  file.append("http-request-log.txt");
  var fos = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream);
  fos.init(file, 0x02 | 0x08 | 0x10, -1, 0); 
  var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
  observerService.addObserver(MIKI, "http-on-modify-request", false);    
  ]]&gt;
  &lt;/script&gt;
  &lt;/window&gt;
  </code></pre>
  
  <p>What i do wrong?</p>