Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Post data with nsIWebNavigation.loadURI

40 views
Skip to first unread message

im...@web.de

unread,
Oct 31, 2006, 1:28:10 PM10/31/06
to
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

0 new messages