From 53b5e8632368c068f0d5b88325bbbf3162066578 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 14 Sep 2009 08:48:30 +0000 Subject: [PATCH] Fix to get iCal in OS X 10.6 working (again): WebDAV RFC 4918 allows a full url or a path as : http://www.webdav.org/specs/rfc4918.html#ELEMENT_href Some clients can NOT deal with one or the other: - KAddressbook (at least in 3.5) can NOT subscribe to addressbooks (it does not find them) if just a path is used - iCal in OS X 10.6 generates wrong requests, if a full url is used --- egw-pear/HTTP/WebDAV/Server.php | 20 ++++++++++++++++---- phpgwapi/inc/class.groupdav.inc.php | 10 ++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/egw-pear/HTTP/WebDAV/Server.php b/egw-pear/HTTP/WebDAV/Server.php index 4943d795b0..520edf3120 100644 --- a/egw-pear/HTTP/WebDAV/Server.php +++ b/egw-pear/HTTP/WebDAV/Server.php @@ -51,6 +51,14 @@ class HTTP_WebDAV_Server */ var $base_uri; + /** + * Set if client requires to be a url (true) or a path (false). + * RFC 4918 allows both: http://www.webdav.org/specs/rfc4918.html#ELEMENT_href + * But some clients can NOT deal with one or the other! + * + * @var boolean + */ + var $client_require_href_as_url; /** * URI path for this request @@ -142,11 +150,15 @@ class HTTP_WebDAV_Server return; } - // default uri is the complete request uri - $uri = (@$this->_SERVER["HTTPS"] === "on" ? "https:" : "http:"); + // default is currently to use just the path, extending class can set $this->client_require_href_as_url depending on user-agent + if ($this->client_require_href_as_url) + { + // default uri is the complete request uri + $uri = (@$this->_SERVER["HTTPS"] === "on" ? "https:" : "http:") . '//'.$this->_SERVER['HTTP_HOST']; + } // we cant use SCRIPT_NAME, because it fails, if there's any url rewriting //error_log("pathinfo:\n". $this->_urldecode($this->_SERVER['REQUEST_URI']).":\n".$this->_SERVER['PATH_INFO']); - $uri.= '//'.$this->_SERVER['HTTP_HOST'].substr($this->_urldecode($this->_SERVER['REQUEST_URI']),0,-strlen($this->_SERVER["PATH_INFO"])); + $uri .= substr($this->_urldecode($this->_SERVER['REQUEST_URI']),0,-strlen($this->_SERVER["PATH_INFO"])); $path_info = empty($this->_SERVER["PATH_INFO"]) ? "/" : $this->_SERVER["PATH_INFO"]; @@ -971,7 +983,7 @@ class HTTP_WebDAV_Server * GET method handler * * @param void - * @returns void + * @return void */ function http_GET() { diff --git a/phpgwapi/inc/class.groupdav.inc.php b/phpgwapi/inc/class.groupdav.inc.php index adb8c9ff68..587f28a119 100644 --- a/phpgwapi/inc/class.groupdav.inc.php +++ b/phpgwapi/inc/class.groupdav.inc.php @@ -90,6 +90,16 @@ class groupdav extends HTTP_WebDAV_Server { if ($this->debug > 2) error_log('groupdav: $_SERVER='.array2string($_SERVER)); + // identify clients, which do NOT support path AND full url in of PROPFIND request + switch(groupdav_handler::get_agent()) + { + case 'kde': // KAddressbook (at least in 3.5 can NOT subscribe / does NOT find addressbook) + $this->client_require_href_as_url = true; + break; + case 'davkit': // iCal app in OS X 10.6 created wrong request, if full url given + $this->client_require_href_as_url = false; + break; + } parent::HTTP_WebDAV_Server(); $this->translation =& $GLOBALS['egw']->translation;