summaryrefslogtreecommitdiffstats
path: root/lib/util.php
diff options
context:
space:
mode:
authorThomas Mueller <thomas.mueller@tmit.eu>2013-02-05 23:33:44 +0100
committerThomas Mueller <thomas.mueller@tmit.eu>2013-02-05 23:33:44 +0100
commit1adcc5fd23004cd7253c87134c30d853e1b3b8b8 (patch)
treebbe413e10172b95eb71cb402ca65b8fc99c793d6 /lib/util.php
parent5221ee0c5aaca5588e20683f397fec9d1d6e98c7 (diff)
downloadnextcloud-server-1adcc5fd23004cd7253c87134c30d853e1b3b8b8.tar.gz
nextcloud-server-1adcc5fd23004cd7253c87134c30d853e1b3b8b8.zip
basic WebDAV test in place now
Diffstat (limited to 'lib/util.php')
-rwxr-xr-xlib/util.php30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/util.php b/lib/util.php
index 4932be2d6cc..ae0900d7e84 100755
--- a/lib/util.php
+++ b/lib/util.php
@@ -514,6 +514,36 @@ 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() {
+ $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.