From 30f32df5588406c7238235e3d3eaa7f028ac2609 Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Fri, 1 Jun 2007 08:06:57 +1200 Subject: [PATCH] Add a DoDELETERequest() method. --- inc/caldav-client.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/inc/caldav-client.php b/inc/caldav-client.php index 4ed90be1..5a5f38c9 100644 --- a/inc/caldav-client.php +++ b/inc/caldav-client.php @@ -96,6 +96,8 @@ class CalDAVClient { curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true ); curl_setopt($this->curl, CURLOPT_BINARYTRANSFER, true ); + $this->headers[] = array(); + } /** @@ -170,6 +172,9 @@ class CalDAVClient { } $this->response = curl_exec($this->curl); + $this->resultcode = curl_getinfo( $this->curl, CURLINFO_HTTP_CODE); + + $this->headers[] = array(); // reset the headers array for our next request return $this->response; } @@ -256,6 +261,27 @@ class CalDAVClient { } + /** + * DELETE a text/icalendar resource + * + * @param string $relative_url The URL to make the request to, relative to $base_url + * @param string $etag The etag of an existing resource to be deleted, or '*' for any resource at that URL. + * + * @return int The HTTP Result Code for the DELETE + */ + function DoDELETERequest( $relative_url, $etag = null ) { + $this->body = ""; + + curl_setopt($this->curl, CURLOPT_CUSTOMREQUEST, "DELETE" ); + curl_setopt($this->curl, CURLOPT_HEADER, true); + if ( $etag != null ) { + $this->SetMatch( false, $etag ); + } + $this->DoRequest($relative_url); + return $this->resultcode; + } + + /** * Get the events in a range from $start to $finish. The dates should be in the * format yyyymmddThhmmssZ and should be in GMT. The events are returned as an