From 33a84595a0c055150d0e9648d0e8e5d68fd97046 Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Thu, 3 May 2012 19:09:48 +1200 Subject: [PATCH] Merge 'Brief' header support into support for "Prefer: return-minimal" Also reduce error noise from sending headers when output might already have started, or trying to flush the output buffer when there isn't one. --- inc/CalDAVRequest.php | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/inc/CalDAVRequest.php b/inc/CalDAVRequest.php index 858d8aa1..bdfd0c7b 100644 --- a/inc/CalDAVRequest.php +++ b/inc/CalDAVRequest.php @@ -106,9 +106,10 @@ class CalDAVRequest public $ticket; /** - * Whether this request included the 'Brief: T' header. + * An array of values from the 'Prefer' header. At present only 'return-minimal' is acted on in any way - you + * can test that value with the PreferMinimal() method. */ - public $brief_response; + private $prefer; /** * Create a new CalDAVRequest object. @@ -118,8 +119,15 @@ class CalDAVRequest $this->options = $options; if ( !isset($this->options['allow_by_email']) ) $this->options['allow_by_email'] = false; - - $this->brief_response = (isset($_SERVER['HTTP_BRIEF']) && (strtoupper($_SERVER['HTTP_BRIEF']) == 'T')); + + if ( isset($_SERVER['HTTP_PREFER']) ) { + $this->prefer = explode( ',', $_SERVER['HTTP_PREFER']); + } + else if ( isset($_SERVER['HTTP_BRIEF']) && (strtoupper($_SERVER['HTTP_PREFER']) == 'T') ) { + $this->prefer = array( 'return-minimal'); + } + else + $this->prefer = array(); /** * Our path is /