http - modify the post data of a request in firefox extension -


i trying trap http request, change of post parameters , send modified request. tried using setdata method of upload stream modify request, same original request sent.

i have following code execute on "http-on-modify-request" :

//rewind request read post body   channel= subject.queryinterface(components.interfaces.nsihttpchannel); channel=channel.queryinterface(components.interfaces.nsiuploadchannel);   channel = channel.uploadstream;   channel.queryinterface(components.interfaces.nsiseekablestream)                 .seek(components.interfaces.nsiseekablestream.ns_seek_set, 0);   var stream = components.classes["@mozilla.org/binaryinputstream;1"]                 .createinstance(components.interfaces.nsibinaryinputstream);   stream.setinputstream(channel);   var postbytes = stream.readbytearray(stream.available());   poststr = string.fromcharcode.apply(null, postbytes);    //change poststr  poststr=poststr.replace(....);   stringstream.setdata(poststr, poststr.length);   //changing postdata   channel = channel.queryinterface(components.interfaces.nsiuploadchannel);   channel = channel.uploadstream;   channel = channel.queryinterface(components.interfaces.nsiseekablestream)           .seek(components.interfaces.nsiseekablestream.ns_seek_set, 0);   channel.uploadstream.queryinterface(components.interfaces.nsimimeinputstream);   channel.uploadstream.setdata(stringstream);   channel.send(); 

what doing wrong here? tried aborting initial request , starting fresh request, page doesn't load @ all. thanx in advance.

hey figured out wrong!! :)

the uploadstream.setdata has bud. sets request method of channel put opposed post need change after setdata call. following seems solve problem :)

channel.uploadstream.setdata(stringstream);    channel.requestmethod = "post";   

@ matrixfrog : right. don't need call channel.send. part taken care of :)


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -