[FR] Connection timeout in URL::DownloadTask

It would be helpful to be able to pass a connection timeout to URL::DownloadTask.

WebInputStream::connect is a blocking if the server has a high load. At least in the case of non-iOS implementations it seems trivial to pass that option on.

Any reason you can’t use the ConnectionTimeoutMs of the InputStream instead?

  if (auto inputStream = URL ("http://www.xyz.com/foobar")
                                 .createInputStream (URL::InputStreamOptions (URL::ParameterHandling::inAddress)
                                                           .withConnectionTimeoutMs (1000)
                                                           .withNumRedirectsToFollow (0)))

Sure that’s how it would work. But it would be convenient to have that functionality also for URL::DownloadTask which already does a lot of useful things.

Use DownloadTask::createFallbackDownloader → pass it your own DownloadTaskOptions, specify a listener with its own timer callback to watch the DownloadTask …

I mean, in case you want a solution that doesn’t require an update to the JUCE framework. Alternatively, I think you can just create your DownloadTask and then set the InputStreamOptions (with timeout) next …

1 Like