From 902219d1542347cd77400c154add34300d0fe48a Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Mon, 4 Jun 2007 23:36:25 +1200 Subject: [PATCH] Refactoring to simplify XMLResponse output. --- inc/CalDAVRequest.php | 13 +++++++++++++ inc/caldav-REPORT.php | 5 +---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/inc/CalDAVRequest.php b/inc/CalDAVRequest.php index dc0d2fa9..a95b301f 100644 --- a/inc/CalDAVRequest.php +++ b/inc/CalDAVRequest.php @@ -456,6 +456,19 @@ class CalDAVRequest } } + /** + * Send an XML Response. This function will never return. + * + * @param int $status The HTTP status to respond + * @param XMLElement $xmltree An XMLElement tree to be rendered + */ + function XMLResponse( $status, $xmltree ) { + $xmldoc = $xmltree->Render(0,''); + $etag = md5($xmldoc); + header("ETag: \"$etag\""); + $request->DoResponse( $status, $xmldoc, 'text/xml; charset="utf-8"' ); + exit(0); // Unecessary, but might clarify things + } /** * Utility function we call when we have a simple status-based response to diff --git a/inc/caldav-REPORT.php b/inc/caldav-REPORT.php index cc6fc9ab..00a14bb3 100644 --- a/inc/caldav-REPORT.php +++ b/inc/caldav-REPORT.php @@ -377,9 +377,6 @@ for ( $i=0; $i <= $reportnum; $i++ ) { } $multistatus = new XMLElement( "multistatus", $responses, array('xmlns'=>'DAV:') ); -$xmldoc = $multistatus->Render(0,''); -$etag = md5($xmldoc); -header("ETag: \"$etag\""); -$request->DoResponse( 207, $xmldoc, 'text/xml; charset="utf-8"' ); +$request->XMLResponse( 207, $multistatus ); ?> \ No newline at end of file