/** * 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 true; } $settings = array('baseUri' => OC_Helper::linkToRemote('webdav')); // save the old timeout so that we can restore it later $old_timeout = ini_get("default_socket_timeout"); // use a 5 sec timeout for the check. Should be enough for local requests. ini_set("default_socket_timeout", 5); $client = new \Sabre_DAV_Client($settings); // for this self test we don't care if the ssl certificate is self signed and the peer cannot be verified. $client->setVerifyPeer(false); $return = true; try { // test PROPFIND $client->propfind('', array('{DAV:}resourcetype')); } catch (\Sabre_DAV_Exception_NotAuthenticated $e) { $return = true; } catch (\Exception $e) { OC_Log::write('core', 'isWebDAVWorking: NO - Reason: ' . $e, OC_Log::WARN); $return = false; } // restore the original timeout ini_set("default_socket_timeout", $old_timeout); return $return; }