Hi all,

I am just trying to set up a small javascript program that posts an HTTP
requests to a web server and processes the corresponding response. Using the
new designed nsIHttpChannel interface I got some difficulties:

// create uri object
var oUrl = Components.classes["@mozilla.org/network/standard-url;1"];
oUrl = oUrl.createInstance(Components.interfaces.nsIURL);
oUrl.spec = http://myhost:port";;

// get io service
oIoService = Components.classes["@mozilla.org/network/io-service;1"];
oIoService = oIoService.getService(Components.interfaces.nsIIOService);

// create http channel
oChannel = oIoService.newChannelFromURI(oUrl);
oChannel = oChannel.QueryInterface(Components.interfaces.nsIHttpChannel);

// create request (just a very simple example here)
oChannel.requestMethod = "post";
oChannel.setRequestHeader("content-type",
"application/x-www-form-urlencoded");

oBody = "arg1=Test&arg2=Test2";

oUploadStream = ?????   // mmh, so here I've got a problem: I need an object
that provides the nsIInputStream interface,  but the only thing I have got
so far is a simple javascript string object. How to go on now??

oChannel.uploadStream = oUploadStream;

// ... and go
oChannel.asyncOpen(myStreamListener, null);
...

Does anyone have an idea how to wrap the string object in something that
provides nsIInputStream??

Thanks, Klaus.





Reply via email to