consistently send ETag by using and extending put_response_headers

This commit is contained in:
Ralf Becker 2012-10-29 12:23:17 +00:00
parent aca3b3b028
commit c327cba153
3 changed files with 30 additions and 15 deletions

View File

@ -813,9 +813,8 @@ class calendar_groupdav extends groupdav_handler
{
$this->groupdav->log(__METHOD__."(,,$user) schedule-tag given, but NO changes for current user events=".array2string($events).', old-event='.array2string($oldEvent));
}
// we should not return an etag here, as we never store the PUT ical byte-by-byte
//header('ETag: "'.$etag.'"');
header('Schedule-Tag: "'.$schedule_tag.'"');
$this->put_response_headers($eventId, $options['path'], '204 No Content', self::$path_attr == 'caldav_name');
return '204 No Content';
}
if ($this->debug && !isset($events)) error_log(__METHOD__."(,,$user) only schedule-tag given for event without participants (only calendar owner) --> handle as regular PUT");
@ -867,14 +866,6 @@ class calendar_groupdav extends groupdav_handler
}
}
if ($this->use_schedule_tag)
{
$etag = $this->get_etag($cal_id, $schedule_tag);
// we should not return an etag here, as we never store the PUT ical byte-by-byte
//header('ETag: "'.$etag.'"');
header('Schedule-Tag: "'.$schedule_tag.'"');
}
// send evtl. necessary respose headers: Location, etag, ...
$this->put_response_headers($cal_id, $options['path'], $retval, self::$path_attr == 'caldav_name');
@ -1315,6 +1306,27 @@ class calendar_groupdav extends groupdav_handler
return $etag;
}
/**
* Send response-headers for a PUT (or POST with add-member query parameter)
*
* Reimplemented to send
*
* @param int|array $entry id or array of new created entry
* @param string $path
* @param int|string $retval
* @param boolean $path_attr_is_name=true true: path_attr is ca(l|rd)dav_name, false: id (GroupDAV needs Location header)
*/
function put_response_headers($entry, $path, $retval, $path_attr_is_name=true)
{
$etag = $this->get_etag($entry, $schedule_tag);
if ($this->use_schedule_tag)
{
header('Schedule-Tag: "'.$schedule_tag.'"');
}
parent::put_response_headers($entry, $path, $retval, $path_attr_is_name, $etag);
}
/**
* Check if user has the neccessary rights on an event
*

View File

@ -1003,6 +1003,7 @@ class groupdav extends HTTP_WebDAV_Server
'DAV:displayname' => 'Displayname',
'DAV:getlastmodified' => 'Last modified',
'DAV:getetag' => 'ETag',
//'CalDAV:schedule-tag' => 'Schedule-Tag',
'DAV:getcontenttype' => 'Content type',
'DAV:resourcetype' => 'Resource type',
//'http://calendarserver.org/ns/:created-by' => 'Created by',

View File

@ -474,18 +474,20 @@ abstract class groupdav_handler
* @param string $path
* @param int|string $retval
* @param boolean $path_attr_is_name=true true: path_attr is ca(l|rd)dav_name, false: id (GroupDAV needs Location header)
* @param string $etag=null etag, to not calculate it again (if != null)
*/
function put_response_headers($entry, $path, $retval, $path_attr_is_name=true)
function put_response_headers($entry, $path, $retval, $path_attr_is_name=true, $etag=null)
{
// we should not return an etag here, as EGroupware never stores ical/vcard byte-by-byte
// as SOGO Connector requires ETag header to recognice as successful PUT, we are sending them again for it
// --> as all clients dislike not getting an ETag for a PUT, we sending it again even not storing byte-by-byte
//if (get_class($this) == 'addressbook_groupdav' && in_array(self::get_agent(),array('thunderbird','lightning')))
{
header('ETag: "'.$this->get_etag($entry).'"');
if (is_null($etag)) $etag = $this->get_etag($entry);
header('ETag: "'.$etag.'"');
}
// send Location header only if we dont use caldav_name as path-attribute or
if ($retval !== true && (!$path_attr_is_name ||
// send Location header only on success AND if we dont use caldav_name as path-attribute or
if (!(is_bool($retval) ? $retval : $retval[0] === '2') && (!$path_attr_is_name ||
// POST with add-member query parameter
$_SERVER['REQUEST_METHOD'] == 'POST' && isset($_GET['add-member'])))
{