juce::URL::downloadToFile() is working on macos but not working on mswin

Client application using JUCE on Mac and Windows needs to download a file from dropbox.com. The url on the dropbox server results in a redirect.

For reference when using the curl utility from the command line, it is necessary to specify the ‘-L’ option. This tells curl to follow http redirects from the server when downloading the file.

In juce_win32_Network.cpp there is some logic to follow redirects, with numRedirectsToFollow defaulting to 5. So far, so good.

However in function openHTTPConnection() in juce_win32_Network.cpp a windows flag is set: INTERNET_FLAG_NO_AUTO_REDIRECT. Which apparently means that when a server responds with a redirect instruction, then the client (JUCE) should not follow the redirect. Result is that the file being requested is never downloaded or received. So there is a kind of a contradiction there in the implementation.

Changing the JUCE code and removing INTERNET_FLAG_NO_AUTO_REDIRECT solves the problem. When the flag is gone the redirect logic in JUCE works correctly and the file is downloaded.

If any other solutions or considerations please advise!

You might try adding
INTERNET_FLAG_NO_AUTO_REDIRECT=0
directly in Projucer under “Preprocessor definitions” and avoid modifying Juce’s files.