I'm not a necko expert and have never done this myself, but I'll take a shot...

On 25 Nov 2006 12:12:50 -0800, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
* Covert target url string to nsIURI [using newURI method from
nsIIOService]
* Create a channel from the Uri [using newChannelFromURI method from
nsIIOService]

Or you could just use nsIIOService::newChannel.

Create Listener
-------------------
*A streamListener implementing the following functions :
onStartRequest, onDataAvailable  , onStopRequest , onChannelRedirect ,
getInterface , onProgress , onStatus , onRedirect and QueryInterface

You probably know it, but for the sake of people who'll find this in
Google, the stream listener is only required to implement the first
three methods - from nsIStreamListener and nsIRequestObserver (+ QI).

The rest can be implemented by another object, which is used to set
the channel's notificationCallbacks property. I don't think necko
attempts to get those from the stream listener.

*Specify a callback function for this listener

Not sure what does this mean. Setting the notificationCallbacks property?

Open channel
------------------
*Open channel specifying a listener I created as parameter ; using the
asyncOpen method on the channel object.

Create InputStream
---------------------------
* of type nsIStringInputStream
* add data to the stream using the setData method

You need to mention the contract id, not just the interface name when
explaining what object you are going to create. I believe you should
look at what getPostDataStream in browser.js does if your code is JS
or use NS_NewPostDataStream if your code is C++.


Create upload channel
------------------------------
* of type nsIUploadChannel
* Call setUpload stream method with the created input stream as
parameter

You already have a channel, you don't need another one. The channel
created in nsIIOService::newChannel should be nsHttpChannel if you
pass it an http(s):// URL. That class implements nsIUploadChannel as
well. So you set the upload stream before opening the channel and I
think it will work fine.

*****************************************************************************************************8

Questions :

* Have I got the steps right ? Am I overdoing/missing something ?

This looks right to me, but I didn't try to do this myself. You can
wait for a guru's answer or you can try and figure out what the code
in docshell does when it needs to send post data.

* For making a HTTP connection, I would guess the nsIHttpChannel has to
be involved somehow ; but I am not currently using it anywhere in my
code . Where would I use it ?

You can QI the channel you have to nsIHttpChannel and get/set
additional information. In particular you may need to manually set the
request method to POST, but I'm unsure if it's done automatically.

* The steps outlined so far establish are for sending data ; how do I
get back error messages/acknowledgements from the server after POSTing
?
The methods on the listener you passed to asyncOpen will be called.

* Is it ok if i cross-post this in the dev-extensions and the dev-mdc
groups or is that frowned upon ?:)

Frowned upon. Pick the right group and post there. In your case the
right group would probably be -network.

dev-mdc is for documentation, what page pointed you there?

Speaking of documentation, it would be great if you found time to
write a short tutorial on what you figured out, once you're done.

Nickolay

Am a n00b, so please be nice :)

_______________________________________________
dev-tech-xpcom mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-xpcom

_______________________________________________
dev-tech-xpcom mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-xpcom

Reply via email to