HTTP communication

Skip to first unread message

Darin Fisher

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.


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

var chan = ...
var uploadChan = chan.QueryInterface(
uploadChan.setUploadStream(content, contentType, contentLen);
var httpChan = chan.QueryInterface(
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.


Reply all
Reply to author
0 new messages