| 421 | | // cURL requires a minimum timeout of 1 second when using the system |
| 422 | | // DNS resolver, as it uses `alarm()`, which is second resolution only. |
| 423 | | // There's no way to detect which DNS resolver is being used from our |
| 424 | | // end, so we need to round up regardless of the supplied timeout. |
| 425 | | // |
| 426 | | // https://github.com/curl/curl/blob/4f45240bc84a9aa648c8f7243be7b79e9f9323a5/lib/hostip.c#L606-L609 |
| 427 | | $timeout = max($options['timeout'], 1); |
| | 421 | $using_asynch_dns = false; |
| | 422 | if (defined('CURL_VERSION_ASYNCHDNS')) { |
| | 423 | $curl_version = curl_version(); |
| | 424 | // phpcs:ignore PHPCompatibility.Constants.NewConstants.curl_version_asynchdnsFound |
| | 425 | if (CURL_VERSION_ASYNCHDNS & $curl_version['features']) { |
| | 426 | $using_asynch_dns = true; |
| | 427 | } |
| | 428 | } |
| | 429 | |
| | 430 | if ($using_asynch_dns) { |
| | 431 | // It should be safe to use any timeout, even if less than 1 second. |
| | 432 | $timeout = $options['timeout']; |
| | 433 | } else { |
| | 434 | // cURL requires a minimum timeout of 1 second when using the system |
| | 435 | // DNS resolver, as it uses `alarm()`, which is second resolution only. |
| | 436 | // There's no way to detect which DNS resolver is being used from our |
| | 437 | // end, so we need to round up regardless of the supplied timeout. |
| | 438 | // |
| | 439 | // https://github.com/curl/curl/blob/4f45240bc84a9aa648c8f7243be7b79e9f9323a5/lib/hostip.c#L606-L609 |
| | 440 | $timeout = max($options['timeout'], 1); |
| | 441 | } |