Refactoring to simplify XMLResponse output.

This commit is contained in:
Andrew McMillan 2007-06-04 23:36:25 +12:00
parent e3ee397008
commit 902219d154
2 changed files with 14 additions and 4 deletions

View File

@ -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,'<?xml version="1.0" encoding="utf-8" ?>');
$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

View File

@ -377,9 +377,6 @@ for ( $i=0; $i <= $reportnum; $i++ ) {
}
$multistatus = new XMLElement( "multistatus", $responses, array('xmlns'=>'DAV:') );
$xmldoc = $multistatus->Render(0,'<?xml version="1.0" encoding="utf-8" ?>');
$etag = md5($xmldoc);
header("ETag: \"$etag\"");
$request->DoResponse( 207, $xmldoc, 'text/xml; charset="utf-8"' );
$request->XMLResponse( 207, $multistatus );
?>