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