Is there any way to signal a download via URL::createInputStream (or another JUCE way to download data) to cancel the download and return?
I noticed OpenStreamProgressCallback, but this seems to rather apply to the upload and also didn’t get called when I tried to use it (maybe I did something wrong).
The problem originates as I’m downloading something in a separate thread (to avoid the GUI being blocked) but as I can’t check for threadShouldExit() during the URL download I need to add a stopThread(timeOutURL) in the thread’s destructor. Due to this, the Application might take up to timeOutURL ms between clicking the close button and being really closed which I’d like to avoid, resulting in the above question.
If you just destroy the inputstream that you’ve created, it should close the stream. Only problem is, I 'm not sure what timeout applies there and how it might vary across different streams.
Thanks for the input. As far as I understand at least on Windows and for smaller files, the url is completely read during the URL::createInputStream() call.If I set a breakpoint and disconnect the network after this line the content is still read.
If I find some time I’ll have a deeper look at the implementation whether there is somer point where the process can be aborted.
It’s just a guess, but instead of creating an InputStream, you could create a WebInputStream instead, check if you need to cancel it before creating the InputStream and calling readEntireStreamAsString().