private function BackupMigrateDropboxAPI::get_curl_handle in Backup and Migrate Dropbox 7.3
Returns the Curl handle.
If no Curl handle has been created yet, one will be created.
Reuse of the curl handle has been seen to be given some performance improvement over creating new handles for each http request. Especially when getting the list of backups, a large number of requests may be sent to Dropbox. But still each request easily takes more than 0.5s, so on large sets of retained back-up files, building this list still takes a considerable amount of time.
Note: it would be better to keep a handle per host as the gain is in setting up the connection (name lookup and connecting with ssl). (@todo?)
A better performance improvement would be downloading multiple (info) files at once, but the Dropbox API does not offer that. The only feature that Dropbox offers is downloading a whole folder at once as a zip, but then the info files would have to be placed in their own folder, not alongside the back-up files themselves. (@todo?)
Return value
resource
Throws
RuntimeException
1 call to BackupMigrateDropboxAPI::get_curl_handle()
- BackupMigrateDropboxAPI::send_http_request in ./
backup_migrate_dropbox.dropbox_api.inc - Executes a curl request.
File
- ./
backup_migrate_dropbox.dropbox_api.inc, line 714
Class
- BackupMigrateDropboxAPI
- BackupMigrateDropboxAPI contains all the details about the Dropbox api, authorization calls, endpoints, uris, parameters, error handling, and split requests for large uploads/downloads
Code
private function get_curl_handle() {
if (empty($this->ch)) {
$this->ch = curl_init();
if (empty($this->ch)) {
throw new RuntimeException('Could not open a Curl session');
}
}
else {
// Reuse the handle but reset the options.
curl_reset($this->ch);
}
return $this->ch;
}