mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 00:29:18 +01:00
full implementation of draft-murchison-webdav-prefer-05, incl. return=representation for 412 conflicts
This commit is contained in:
parent
8d5c4138bc
commit
86649cd1e1
@ -774,6 +774,8 @@ class calendar_groupdav extends groupdav_handler
|
|||||||
if ($schedule_tag_match !== $schedule_tag)
|
if ($schedule_tag_match !== $schedule_tag)
|
||||||
{
|
{
|
||||||
if ($this->debug) error_log(__METHOD__."(,,$user) schedule_tag missmatch: given '$schedule_tag_match' != '$schedule_tag'");
|
if ($this->debug) error_log(__METHOD__."(,,$user) schedule_tag missmatch: given '$schedule_tag_match' != '$schedule_tag'");
|
||||||
|
// honor Prefer: return=representation for 412 too (no need for client to explicitly reload)
|
||||||
|
$this->check_return_representation($options, $id, $user);
|
||||||
return '412 Precondition Failed';
|
return '412 Precondition Failed';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -891,6 +893,8 @@ class calendar_groupdav extends groupdav_handler
|
|||||||
}
|
}
|
||||||
elseif ($cal_id === 0) // etag failure
|
elseif ($cal_id === 0) // etag failure
|
||||||
{
|
{
|
||||||
|
// honor Prefer: return=representation for 412 too (no need for client to explicitly reload)
|
||||||
|
$this->check_return_representation($options, $id, $user);
|
||||||
return '412 Precondition Failed';
|
return '412 Precondition Failed';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -309,6 +309,8 @@ abstract class groupdav_handler
|
|||||||
if ($this->http_if_match !== $etag)
|
if ($this->http_if_match !== $etag)
|
||||||
{
|
{
|
||||||
if ($this->debug) error_log(__METHOD__."($method,path=$options[path],$id) HTTP_IF_MATCH='$_SERVER[HTTP_IF_MATCH]', etag='$etag': 412 Precondition failed".array2string($entry));
|
if ($this->debug) error_log(__METHOD__."($method,path=$options[path],$id) HTTP_IF_MATCH='$_SERVER[HTTP_IF_MATCH]', etag='$etag': 412 Precondition failed".array2string($entry));
|
||||||
|
// honor Prefer: return=representation for 412 too (no need for client to explicitly reload)
|
||||||
|
$this->check_return_representation($options, $id);
|
||||||
return '412 Precondition Failed';
|
return '412 Precondition Failed';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -327,6 +329,8 @@ abstract class groupdav_handler
|
|||||||
if ($method == 'PUT' && ($if_none_match == '*' || $if_none_match == $etag))
|
if ($method == 'PUT' && ($if_none_match == '*' || $if_none_match == $etag))
|
||||||
{
|
{
|
||||||
if ($this->debug) error_log(__METHOD__."($method,,$id) HTTP_IF_NONE_MATCH='$_SERVER[HTTP_IF_NONE_MATCH]', etag='$etag': 412 Precondition failed");
|
if ($this->debug) error_log(__METHOD__."($method,,$id) HTTP_IF_NONE_MATCH='$_SERVER[HTTP_IF_NONE_MATCH]', etag='$etag': 412 Precondition failed");
|
||||||
|
// honor Prefer: return=representation for 412 too (no need for client to explicitly reload)
|
||||||
|
$this->check_return_representation($options, $id);
|
||||||
return '412 Precondition Failed';
|
return '412 Precondition Failed';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -344,7 +348,8 @@ abstract class groupdav_handler
|
|||||||
*/
|
*/
|
||||||
public function check_return_representation($options, $id, $user=null)
|
public function check_return_representation($options, $id, $user=null)
|
||||||
{
|
{
|
||||||
if (isset($_SERVER['HTTP_PREFER']) && in_array('return=representation', explode(',', $_SERVER['HTTP_PREFER'])))
|
//error_log(__METHOD__."(, $id, $user) start ".function_backtrace());
|
||||||
|
if (isset($_SERVER['HTTP_PREFER']) && in_array('return=representation', preg_split('/, ?/', $_SERVER['HTTP_PREFER'])))
|
||||||
{
|
{
|
||||||
if ($_SERVER['REQUEST_METHOD'] == 'POST')
|
if ($_SERVER['REQUEST_METHOD'] == 'POST')
|
||||||
{
|
{
|
||||||
@ -355,6 +360,11 @@ abstract class groupdav_handler
|
|||||||
}
|
}
|
||||||
header('Content-Location: '.$location);
|
header('Content-Location: '.$location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// remove If-Match or If-None-Match headers, otherwise HTTP status 412 goes into endless loop!
|
||||||
|
unset($_SERVER['HTTP_IF_MATCH']);
|
||||||
|
unset($_SERVER['HTTP_IF_NONE_MATCH']);
|
||||||
|
|
||||||
if (($ret = $this->get($options, $id ? $id : $this->new_id, $user)) && !empty($options['data']))
|
if (($ret = $this->get($options, $id ? $id : $this->new_id, $user)) && !empty($options['data']))
|
||||||
{
|
{
|
||||||
header('Content-Length: '.$this->groupdav->bytes($options['data']));
|
header('Content-Length: '.$this->groupdav->bytes($options['data']));
|
||||||
@ -362,6 +372,7 @@ abstract class groupdav_handler
|
|||||||
echo $options['data'];
|
echo $options['data'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//error_log(__METHOD__."(, $id, $user) returning ".array2string($ret));
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user