problems with HTLoadToFile

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

problems with HTLoadToFile

Vitaliy Yunikov

I just started working with libwww and I have a question concerning file
download. To download a file I use HTLoadToFile function, and I want
to run it in separate thread. I also want to have possibility to stop
the download by user request. I've read a lot of libwww docs and I've
seen a lot of examples, but I still don't know how to do this.

So, is there some API to stop download after it is started?

--
Best regards,
 Vitaliy                          mailto:[hidden email]




Reply | Threaded
Open this post in threaded view
|

Re: problems with HTLoadToFile

Sam Varshavchik
Vitaliy Yunikov writes:

>
> I just started working with libwww and I have a question concerning file
> download. To download a file I use HTLoadToFile function, and I want
> to run it in separate thread. I also want to have possibility to stop
> the download by user request. I've read a lot of libwww docs and I've
> seen a lot of examples, but I still don't know how to do this.
>
> So, is there some API to stop download after it is started?

HTLoadToFile is just a single-purpose convenience function that quickly
dumps a URL to a file. That's it. No frills. Just a straightforward content
grab.

The only way to do what you need to do is to manually construct an HTRequest
object, create your own subclass of HTStreamClass, then use
HTLoadToStream(), and, in your own stream's putc/puts/putblock callback,
dump the data to your file. If your callback function returns HT_ERR instead
of HT_OK, libwww should abort and unwind everything.

You can look at some sample code here:

http://lpmtool.cvs.sourceforge.net/lpmtool/lpm/www/wwwfuncs.C?view=markup



attachment0 (196 bytes) Download Attachment