Bug 681148 - Define getPostDataStream() as in Firefox r=IanN a=comm-aurora a=comm-beta.
authorStanimir Stamenkov <stamenkov@gmail.com>
Mon, 29 Aug 2011 20:57:52 +0300
changeset 8792 ceb61068f6e7685cf39a0ea9d010517afd9b24dc
parent 8791 433133e6ec86f10fe15616d83c13574fbcf2d3dc
child 8793 8d6af20d3293cd595717eacb9eaf32d8b6fbb8fb
push id158
push userbugzilla@standard8.plus.com
push dateTue, 27 Sep 2011 19:18:14 +0000
treeherdercomm-beta@e47b99c61e4d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersIanN, comm-aurora, comm-beta
bugs681148
Bug 681148 - Define getPostDataStream() as in Firefox r=IanN a=comm-aurora a=comm-beta. Copied and adjusted getPostDataStream() from Firefox "browser.js".
suite/browser/navigator.js
--- a/suite/browser/navigator.js
+++ b/suite/browser/navigator.js
@@ -1776,16 +1776,31 @@ function getShortcutOrURI(aURL, aPostDat
     aPostDataRef.value = null;
 
     return aURL;
   }
 
   return shortcutURL;
 }
 
+function getPostDataStream(aStringData, aKeyword, aEncKeyword, aType)
+{
+  var dataStream = Components.classes["@mozilla.org/io/string-input-stream;1"]
+                             .createInstance(Components.interfaces.nsIStringInputStream);
+  aStringData = aStringData.replace(/%s/g, aEncKeyword).replace(/%S/g, aKeyword);
+  dataStream.data = aStringData;
+
+  var mimeStream = Components.classes["@mozilla.org/network/mime-input-stream;1"]
+                             .createInstance(Components.interfaces.nsIMIMEInputStream);
+  mimeStream.addHeader("Content-Type", aType);
+  mimeStream.addContentLength = true;
+  mimeStream.setData(dataStream);
+  return mimeStream.QueryInterface(Components.interfaces.nsIInputStream);
+}
+
 function handleDroppedLink(event, url, name)
 {
   var postData = { };
   var uri = getShortcutOrURI(url, postData);
   if (uri)
     loadURI(uri, null, postData.value, false);
 
   // Keep the event from being handled by the dragDrop listeners