PHP 8.4: Curl: New CURLOPT_SERVER_RESPONSE_TIMEOUT option to replace CURLOPT_FTP_RESPONSE_TIMEOUT

Version8.4
TypeNew Feature

The Curl extension supports specifying a server time-out period (in seconds) that the server is allowed to take in order to send a response message for a command before the session is considered dead.

This option was previously used only in FTP, and Curl has since expanded support to other protocols such as SFTP, SCP, IMAP, POP3, and SMTP. Because its first use was in FTP, the option was called CURLOPT_FTP_RESPONSE_TIMEOUT, and PHP supports it in all current PHP versions. However, libcurl 7.85 deprecates this option in favor of the new option CURLOPT_SERVER_RESPONSE_TIMEOUT. Internally, both constants hold the same int value (112).

PHP 8.4 and later declares a new constant called CURLOPT_SERVER_RESPONSE_TIMEOUT that holds the same value as the existing CURLOPT_FTP_RESPONSE_TIMEOUT constant. Existing applications that use the CURLOPT_FTP_RESPONSE_TIMEOUT constant can continue to use it because it is not deprecated.

However, if the application only runs on PHP 8.4 and later, it is recommended to replace CURLOPT_FTP_RESPONSE_TIMEOUT constant references with CURLOPT_SERVER_RESPONSE_TIMEOUT.

In functionality, both CURLOPT_FTP_RESPONSE_TIMEOUT and CURLOPT_SERVER_RESPONSE_TIMEOUT are identical.

Backward Compatibility Impact

It is possible to back-port the new CURLOPT_SERVER_RESPONSE_TIMEOUT constant to older PHP versions merely by declaring it in the global namespace.

if (\PHP_VERSION_ID < 80400) {
    define('CURLOPT_SERVER_RESPONSE_TIMEOUT', 112);
}

CURLOPT_SERVER_RESPONSE_TIMEOUT CURLOPT_FTP_RESPONSE_TIMEOUT Implementation