diff options
author | Vincent Petry <pvince81@owncloud.com> | 2013-10-18 01:10:04 -0700 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2013-10-18 01:10:04 -0700 |
commit | 11cfb9dc48383ad3cb3aa5c5871e0135cfef17b5 (patch) | |
tree | df6ec91c4978cb57035056cd6d35ad227e835242 | |
parent | 76be7cd1ac54a8f4a5707c7a50eee106383aa51d (diff) | |
parent | b1f72edc5705f3d5eb5f8910e2e14d0fa9805222 (diff) | |
download | nextcloud-server-11cfb9dc48383ad3cb3aa5c5871e0135cfef17b5.tar.gz nextcloud-server-11cfb9dc48383ad3cb3aa5c5871e0135cfef17b5.zip |
Merge pull request #5358 from owncloud/postinstall-ocdavclientwithtimeout
Added timeout for WebDAV post setup check
-rw-r--r-- | lib/private/davclient.php | 46 | ||||
-rwxr-xr-x | lib/private/util.php | 4 |
2 files changed, 49 insertions, 1 deletions
diff --git a/lib/private/davclient.php b/lib/private/davclient.php new file mode 100644 index 00000000000..28f48f3b921 --- /dev/null +++ b/lib/private/davclient.php @@ -0,0 +1,46 @@ +<?php +/** + * ownCloud + * + * @author Vincent Petry + * @copyright 2013 Vincent Petry <pvince81@owncloud.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + * + */ + +/** + * This class extends the SabreDAV client with additional functionality + * like request timeout. + */ + +class OC_DAVClient extends \Sabre_DAV_Client { + + protected $requestTimeout; + + /** + * @brief Sets the request timeout or 0 to disable timeout. + * @param int timeout in seconds or 0 to disable + */ + public function setRequestTimeout($timeout) { + $this->requestTimeout = (int)$timeout; + } + + protected function curlRequest($url, $settings) { + if ($this->requestTimeout > 0) { + $settings[CURLOPT_TIMEOUT] = $this->requestTimeout; + } + return parent::curlRequest($url, $settings); + } +} diff --git a/lib/private/util.php b/lib/private/util.php index 6c0a8d7bab5..43f2c9bb635 100755 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -806,7 +806,9 @@ class OC_Util { 'baseUri' => OC_Helper::linkToRemote('webdav'), ); - $client = new \Sabre_DAV_Client($settings); + $client = new \OC_DAVClient($settings); + + $client->setRequestTimeout(10); // for this self test we don't care if the ssl certificate is self signed and the peer cannot be verified. $client->setVerifyPeer(false); |