Incorrect docs for URL::InputStreamOptions

This is what the docs show for URL::InputStreamOptions::withConnectionTimeoutMs:

InputStreamOptions URL::InputStreamOptions::withConnectionTimeoutMs	(	int 	connectionTimeoutMs	)	const
Specifies a timeout for the request in milliseconds.

If 0, this will use whatever default setting the OS chooses. 
If a negative number, it will be infinite.

On macOS, this is what happens in when the connection is created before being launched:

    void createConnection()
        jassert (connection == nullptr);

        if (NSURL* nsURL = [NSURL URLWithString: juceStringToNS (url.toString (! addParametersToRequestBody))])
            if (NSMutableURLRequest* req = [NSMutableURLRequest requestWithURL: nsURL
                                                                   cachePolicy: NSURLRequestReloadIgnoringLocalCacheData
                                                               timeoutInterval: timeOutMs <= 0 ? 60.0 : (timeOutMs / 1000.0)])

this is the important part:

timeoutInterval: timeOutMs <= 0 ? 60.0 : (timeOutMs / 1000.0)])

If the user supplies a 0 or negative value, the timeout is set to 60 seconds, not infinite.

on Windows juce_win32_Network.cpp, the timeout is set as follows:

    void openConnection (URL_COMPONENTS& uc, HINTERNET sessionHandle,
                         const String& address,
                         WebInputStream::Listener* listener)
        int disable = 1;
        InternetSetOption (sessionHandle, INTERNET_OPTION_DISABLE_AUTODIAL, &disable, sizeof (disable));

        if (timeOutMs == 0)
            timeOutMs = 30000;
        else if (timeOutMs < 0)
            timeOutMs = -1;

Does macOS support infinite timeouts for Web connections?

NSMutableURLRequest doesn’t support a special-case “infinite” for the timeoutInterval parameter, but it looks like the code is incorrect in assuming that <= 0 == “default” which is 60s. We can use inf though which should be long enough. I’ve added that here:

Quick question.

I’ve noticed a lot of updates to the framework that involve the use of these anonymous lambdas that are called automatically to fill in a value. What’s the reasoning behind this code style change?

Using an immediately invoked lambda means we can make timeOutSeconds const instead of something like:

double timeOutSeconds = 0.0;

if (timeOutMs > 0)
    timeOutSeconds = timeOutMs / 1000.0;
    timeOutSeconds = timeOutMs < 0 ? std::numeric_limits<double>::infinity() : 60.0;

what is the benefit besides using more const variables in the code?
are there performance benefits?

This is a good article on the topic: