1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-31 15:32:27 +01:00

Allow passing strings or arrays as postData parameters to dactyl.open.

This commit is contained in:
Kris Maglione
2012-03-13 17:52:22 -04:00
parent cab8f93eef
commit 7479e92d39
2 changed files with 13 additions and 0 deletions

View File

@@ -952,6 +952,18 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
loc = { url: loc[0], postData: loc[1] };
else if (isString(loc))
loc = { url: loc };
else
loc = Object.create(loc);
if (isString(loc.postData))
loc.postData = ["application/x-www-form-urlencoded", loc.postData];
if (isArray(loc.postData)) {
let stream = services.MIMEStream(services.StringStream(loc.postData[1]));
stream.addHeader("Content-Type", loc.postData[0]);
stream.addContentLength = true;
loc.postData = stream;
}
// decide where to load the first url
switch (where) {

View File

@@ -92,6 +92,7 @@ var Services = Module("Services", {
this.addClass("HtmlEncoder", "@mozilla.org/layout/htmlCopyEncoder;1", "nsIDocumentEncoder");
this.addClass("InterfacePointer", "@mozilla.org/supports-interface-pointer;1", "nsISupportsInterfacePointer", "data");
this.addClass("InputStream", "@mozilla.org/scriptableinputstream;1", "nsIScriptableInputStream", "init");
this.addClass("MIMEStream", "@mozilla.org/network/mime-input-stream;1", "nsIMIMEInputStream", "setData");
this.addClass("Persist", "@mozilla.org/embedding/browser/nsWebBrowserPersist;1", "nsIWebBrowserPersist");
this.addClass("Pipe", "@mozilla.org/pipe;1", "nsIPipe", "init");
this.addClass("Process", "@mozilla.org/process/util;1", "nsIProcess", "init");