Re: downloading a file via HTTP w/ XPCOM and JS

Adam Fletcher <[email protected]> Wed, 30 Oct 2002 10:27:59 -0500
Newsgroups gmane.comp.mozilla.devel.xpcom
Organization Another Netscape Collabra Server User
Message-ID <[email protected]>
Mike,

I solved this later that same day by creating the nsIURL - thanks for 
the advice.

-Adam

Mike Lee wrote:
> You probabily didn't use nsIURL to wrapp the url. In mozblog there is a 
> example of how to use it. Check [1] function preFetchWebsite() and 
> httpListener.
> 
> Regards
> 
> [1] 
> http://www.mozdev.org/source/browse/mozblog/content/discuss/editorExtension.js?rev=1.3&content-type=text/x-cvsweb-markup 
> 
> 
> Adam Fletcher wrote:
> 
>> Hi everyone,
>>
>> I'm looking for an example of how to download a file using Javascript, 
>> XPCOM and HTTP. I'd like to do this entirely with XPCOM.
>>
>> My best start, which doesn't work:
>>
>> var ioService = getService('@mozilla.org/network/io-service;1',
>>                             'nsIIOService');
>> var chann = ioService.newChannelFromURI(someURL).QueryInterface( 
>>                             Components.interfaces.nsIHttpChannel);
>>
>> // someFileListerner has onStopRequest, onStartRequest, etc..
>> chann.asyncOpen(someFileListener, null);
>>
>>
>> Any help would be appreciated.
>>
>> Thanks,
>>
>> Adam Fletcher
>>
> 
>