title: How to send a POST request from a Firefox extension?
body: <p>I would like to send a POST request to a web server from a firefox extension.</p>
  
  <p>I have found this example to send POST requests;
  <a href="https://developer.mozilla.org/en/Creating_Sandboxed_HTTP_Connections#HTTP_notifications" rel="nofollow">https://developer.mozilla.org/en/Creating_Sandboxed_HTTP_Connections#HTTP_notifications</a></p>
  
  <p>but I can't get it to work.</p>
  
  <p>I currently have code like this;</p>
  
  <pre><code>    var ioService = Components.classes["@mozilla.org/network/io-service;1"]
                                .getService(Components.interfaces.nsIIOService);
  var uri = ioService.newURI("http://www.google.com", null, null);
  gChannel = ioService.newChannelFromURI(uri);
  
  postData = "a=1&amp;b=2&amp;c=3";
  
  var inputStream = Components.classes["@mozilla.org/io/string-input-stream;1"]
      .createInstance(Components.interfaces.nsIStringInputStream);
  
  inputStream.setData(postData, postData.length);
  
  var uploadChannel = gChannel.QueryInterface(Components.interfaces.nsIUploadChannel);
  
  uploadChannel.setUploadStream(inputStream, "application/x-www-form-urlencoded", -1);
  uploadChannel.requestMethod = "POST";
  uploadChannel.open();
  </code></pre>
  
  <p>but I get an error about "cant modify properties of a WrappedNative"</p>