aboutsummaryrefslogtreecommitdiffstats
path: root/lib/util.php
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2013-02-09 17:28:30 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2013-02-09 17:28:30 +0100
commitd67d9566ce37e63c4df62d1f57fb03540421895c (patch)
tree5b6d5d0002f962f04c4706b3a722991a8e68c6ab /lib/util.php
parent9dddcae9ca3dcf872893e36e2f478ebecafdc6e2 (diff)
parent5a309c11ca90589303c38084795432d3d23e393d (diff)
downloadnextcloud-server-d67d9566ce37e63c4df62d1f57fb03540421895c.tar.gz
nextcloud-server-d67d9566ce37e63c4df62d1f57fb03540421895c.zip
Merge branch 'master' into clean-app-id
Diffstat (limited to 'lib/util.php')
-rwxr-xr-xlib/util.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/util.php b/lib/util.php
index 9ce974619bc..49d914e5fbd 100755
--- a/lib/util.php
+++ b/lib/util.php
@@ -516,6 +516,40 @@ class OC_Util {
}
}
+ /**
+ * we test if webDAV is working properly
+ *
+ * The basic assumption is that if the server returns 401/Not Authenticated for an unauthenticated PROPFIND
+ * the web server it self is setup properly.
+ *
+ * Why not an authenticated PROFIND and other verbs?
+ * - We don't have the password available
+ * - We have no idea about other auth methods implemented (e.g. OAuth with Bearer header)
+ *
+ */
+ public static function isWebDAVWorking() {
+ if (!function_exists('curl_init')) {
+ return;
+ }
+
+ $settings = array(
+ 'baseUri' => OC_Helper::linkToRemote('webdav'),
+ );
+
+ $client = new \Sabre_DAV_Client($settings);
+
+ $return = true;
+ try {
+ // test PROPFIND
+ $client->propfind('', array('{DAV:}resourcetype'));
+ } catch(\Sabre_DAV_Exception_NotAuthenticated $e) {
+ $return = true;
+ } catch(\Exception $e) {
+ $return = false;
+ }
+
+ return $return;
+ }
/**
* Check if the setlocal call doesn't work. This can happen if the right local packages are not available on the server.