From 9eff8f92ae56dab8f5e81e9d369666190bd8b8d5 Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Tue, 5 Dec 2006 00:51:41 +1300 Subject: [PATCH] As a basic checkpoint we are now creating a lock for a resource. --- inc/CalDAVRequest.php | 65 +++++++- inc/caldav-LOCK.php | 154 ++++++++++++++++++ .../regression-suite/800-Spec-LOCK-1.result | 0 .../regression-suite/800-Spec-LOCK-1.test | 2 +- 4 files changed, 214 insertions(+), 7 deletions(-) create mode 100644 testing/tests/regression-suite/800-Spec-LOCK-1.result diff --git a/inc/CalDAVRequest.php b/inc/CalDAVRequest.php index d3e08c6d..77561511 100644 --- a/inc/CalDAVRequest.php +++ b/inc/CalDAVRequest.php @@ -14,6 +14,8 @@ * @license http://gnu.org/copyleft/gpl.html GNU GPL v2 */ +define('DEPTH_INFINITY', 9999); + /** * A class for collecting things to do with this request. * @@ -21,7 +23,6 @@ */ class CalDAVRequest { - const DEPTH_INFINITY = 9999; /** * Create a new CalDAVRequest object. @@ -40,7 +41,7 @@ class CalDAVRequest * A variety of requests may set the "Depth" header to control recursion */ $this->depth = ( isset($_SERVER['HTTP_DEPTH']) ? $_SERVER['HTTP_DEPTH'] : 0 ); - if ( $this->depth == 'infinity' ) $this->depth = self::DEPTH_INFINITY; + if ( $this->depth == 'infinity' ) $this->depth = DEPTH_INFINITY; $this->depth = intval($this->depth); /** @@ -55,6 +56,24 @@ class CalDAVRequest if ( isset($_SERVER['HTTP_IF']) ) $this->if_clause = $_SERVER['HTTP_IF']; if ( isset($_SERVER['HTTP_LOCK-TOKEN']) ) $this->lock_token = $_SERVER['HTTP_LOCK-TOKEN']; + /** + * LOCK things use a "Timeout" header to set a series of reducing alternative values + */ + if ( isset($_SERVER['HTTP_TIMEOUT']) ) { + $timeouts = split( ',', $_SERVER['HTTP_TIMEOUT'] ); + foreach( $timeouts AS $k => $v ) { + if ( strtolower($v) == 'infinite' ) { + $this->timeout = (isset($c->maximum_lock_timeout) ? $c->maximum_lock_timeout : 86400 * 100); + break; + } + elseif ( strtolower(substr($v,0,7)) == 'second-' ) { + $this->timeout = max( intval(substr($v,7)), (isset($c->maximum_lock_timeout) ? $c->maximum_lock_timeout : 86400 * 100) ); + break; + } + } + if ( ! isset($this->timeout) ) $this->timeout = (isset($c->default_lock_timeout) ? $c->default_lock_timeout : 900); + } + /** * Our path is /