From 1ac7a8535b635a4e6efe66ef96cda3bb90a3e44c Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 20 May 2008 09:02:16 +0000 Subject: [PATCH] "fixed 2 problems: - new entry were not handled correct after the last commits (201 Created and Loaction header) - cadaver reports entires as not found, because modified and contentlength were not set" --- .../inc/class.addressbook_groupdav.inc.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/addressbook/inc/class.addressbook_groupdav.inc.php b/addressbook/inc/class.addressbook_groupdav.inc.php index 8ef12c620d..4b5f968b0b 100644 --- a/addressbook/inc/class.addressbook_groupdav.inc.php +++ b/addressbook/inc/class.addressbook_groupdav.inc.php @@ -114,10 +114,18 @@ class addressbook_groupdav extends groupdav_handler $props = array( HTTP_WebDAV_Server::mkprop('getetag',$this->get_etag($contact)), HTTP_WebDAV_Server::mkprop('getcontenttype', 'text/x-vcard'), + // getlastmodified and getcontentlength are required by WebDAV and Cadaver eg. reports 404 Not found if not set + HTTP_WebDAV_Server::mkprop('getlastmodified', $contact['modified']), ); if ($address_data) { - $props[] = HTTP_WebDAV_Server::mkprop(groupdav::CARDDAV,'address-data',$handler->getVCard($contact,$this->charset)); + $content = $handler->getVCard($contact,$this->charset); + $props[] = HTTP_WebDAV_Server::mkprop('getcontentlength',bytes($content)); + $props[] = HTTP_WebDAV_Server::mkprop(groupdav::CARDDAV,'address-data',$content=$handler->getVCard($contact,$this->charset)); + } + else + { + $props[] = HTTP_WebDAV_Server::mkprop('getcontentlength', ''); // expensive to calculate and no CalDAV client uses it } $files['files'][] = array( 'path' => self::get_path($contact), @@ -255,10 +263,10 @@ class addressbook_groupdav extends groupdav_handler } if ($this->http_if_match) $contact['etag'] = self::etag2value($this->http_if_match); - if (!($ok = $this->bo->save($contact))) + if (!($save_ok = $this->bo->save($contact))) { - if ($this->debug) error_log(__METHOD__."(,$id) save(".array2string($contact).") failed, Ok=$ok"); - if ($ok === 0) + if ($this->debug) error_log(__METHOD__."(,$id) save(".array2string($contact).") failed, Ok=$save_ok"); + if ($save_ok === 0) { return '412 Precondition Failed'; }