@@ -132,6 +132,11 @@ class Codebird
132
132
*/
133
133
protected $ _connectionTimeout = 3000 ;
134
134
135
+ /**
136
+ * Remote media download timeout
137
+ */
138
+ protected $ _remoteDownloadTimeout = 5000 ;
139
+
135
140
/**
136
141
* Proxy
137
142
*/
@@ -265,6 +270,18 @@ public function setConnectionTimeout($timeout)
265
270
$ this ->_connectionTimeout = (int ) $ timeout ;
266
271
}
267
272
273
+ /**
274
+ * Sets remote media download timeout in milliseconds
275
+ *
276
+ * @param int $timeout Remote media timeout in milliseconds
277
+ *
278
+ * @return void
279
+ */
280
+ public function setRemoteDownloadTimeout ($ timeout )
281
+ {
282
+ $ this ->_remoteDownloadTimeout = (int ) $ timeout ;
283
+ }
284
+
268
285
/**
269
286
* Sets the format for API replies
270
287
*
@@ -1292,8 +1309,8 @@ protected function _getMultipartRequestFromParams($possible_files, $border, $par
1292
1309
curl_setopt ($ ch , CURLOPT_SSL_VERIFYPEER , 0 );
1293
1310
curl_setopt ($ ch , CURLOPT_SSL_VERIFYHOST , 0 );
1294
1311
// use hardcoded download timeouts for now
1295
- curl_setopt ($ ch , CURLOPT_TIMEOUT_MS , 5000 );
1296
- curl_setopt ($ ch , CURLOPT_CONNECTTIMEOUT_MS , 2000 );
1312
+ curl_setopt ($ ch , CURLOPT_TIMEOUT_MS , $ this -> _remoteDownloadTimeout );
1313
+ curl_setopt ($ ch , CURLOPT_CONNECTTIMEOUT_MS , $ this -> _remoteDownloadTimeout / 2 );
1297
1314
// find files that have been redirected
1298
1315
curl_setopt ($ ch , CURLOPT_FOLLOWLOCATION , true );
1299
1316
// process compressed images
@@ -1307,7 +1324,7 @@ protected function _getMultipartRequestFromParams($possible_files, $border, $par
1307
1324
'http ' => [
1308
1325
'method ' => 'GET ' ,
1309
1326
'protocol_version ' => '1.1 ' ,
1310
- 'timeout ' => 5000
1327
+ 'timeout ' => $ this -> _remote_download_timeout
1311
1328
],
1312
1329
'ssl ' => [
1313
1330
'verify_peer ' => false
0 commit comments