$host], '', '&', PHP_QUERY_RFC3986); $ch = curl_init($url); $body = ''; if ($ch === false) throw new \RuntimeException('TRANSPORT'); try { curl_setopt_array($ch, [ CURLOPT_FOLLOWLOCATION => false, CURLOPT_PROTOCOLS => CURLPROTO_HTTPS, CURLOPT_SSL_VERIFYPEER => true, CURLOPT_SSL_VERIFYHOST => 2, CURLOPT_CONNECTTIMEOUT => Backups::limit($config, 'connect_timeout_seconds', 2, 1, 10), CURLOPT_TIMEOUT => Backups::limit($config, 'timeout_seconds', 5, 1, 30), CURLOPT_HTTPAUTH => CURLAUTH_BASIC, CURLOPT_USERNAME => $user, CURLOPT_PASSWORD => $password, CURLOPT_WRITEFUNCTION => static function ($ch, string $chunk) use (&$body, $config): int { if (strlen($body) + strlen($chunk) > Backups::limit($config, 'max_response_bytes', 2097152, 1024, 2097152)) return 0; $body .= $chunk; return strlen($chunk); }, ]); if (curl_exec($ch) === false || curl_getinfo($ch, CURLINFO_HTTP_CODE) !== 200) throw new \RuntimeException('HTTP'); return $body; } finally { curl_close($ch); } } }