Post data with webNavigation.loadURI

B

Björn Langhof

Hallo.

I'd like to post data from a Firefox extension.

The HTML-Formular I want to fake looks like this

<form action="http://homepage/phpinfo.php" method="post">
<input name="name" value="foo">
<input name="id" value="bar">
</form>


The code I use is this:

var body = '\r\nname=foo&id=bar\r\n';
var webNav =
_content.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
getInterface(Components.interfaces.nsIWebNavigation);

var sis = Components.classes["@mozilla.org/io/string-input-stream;1"].
createInstance(Components.interfaces.nsIStringInputStream);

sis.setData(body, body.length);

document.getElementById("content").webNavigation.loadURI('http://homepage/phpinfo.php',
0, null, sis, null);


The requested page is opened and displayed. But there is no post data at
all.

Now I've installed the Firefox-Extension tamper to monitor the HTTP-Header.
For the HTML-Formular the table of the post-parameter looks like this:
Name: Value:
name foo
id bar

For my loadURI-request:
Name: Value:
POST_DATA name=foo&id=bar

So there seems to be something wrong. But I can't figure out what's
wrong and how to fix it. Do you have any suggestions?

Thanks for your help.

Greetings,
Björn
 
B

Björn Langhof

Björn Langhof said:
I'd like to post data from a Firefox extension.
[...]

So there seems to be something wrong. But I can't figure out what's
wrong and how to fix it. Do you have any suggestions?

Does nobody know the answer or is this the wrong newsgroup for this
question? Unfortunately in mozilla.dev.extensions there is also no reply.

Hoping desperately for help. Greetings,
BJörn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top