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

HTTP communication

0 views
Skip to first unread message

Darin Fisher

unread,
Mar 31, 2003, 3:26:40 PM3/31/03
to Tom Lee
Tom Lee wrote:
> Hello,
>
> I have been looking for an example on how to use the HTTP functionality
> properly. I am particularly interested in POST, GET, ect... The application
> that I am currently working on needs to post an extremely large amount of
> data - so I would be in a loop sending 2k buffers with each iteration. Anty
> helop would be greatly appreciated.
>
>


tom,

you will need to use nsIUploadChannel and nsIHttpChannel to setup a post
request. here's some sample code:

var chan = ...
var uploadChan = chan.QueryInterface(
Components.interfaces.nsIUploadChannel);
uploadChan.setUploadStream(content, contentType, contentLen);
var httpChan = chan.QueryInterface(
Components.interfaces.nsIHttpChannel);
httpChan.method = "POST";

now, when you call "asyncOpen" on the channel, it will issue a HTTP POST
request instead of a GET. it will send the data contained in "content".
content must support nsIInputStream. you can either provide your own
implementation of nsIInputStream or use one of the existing
implementations found in xpcom/io, but beware none of the existing
implementations are frozen.

darin

0 new messages