From b3c2c9db3c111b166517ce4e0a3f390460005984 Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Wed, 4 Apr 2012 23:12:46 +1200 Subject: [PATCH] Extract HTTP response code for DELETE. Delete unused attribute, mark httpResponseHeaders / httpResponseBody as protected. --- inc/caldav-client-v2.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/inc/caldav-client-v2.php b/inc/caldav-client-v2.php index 9d4db7d6..3547bb2e 100644 --- a/inc/caldav-client-v2.php +++ b/inc/caldav-client-v2.php @@ -76,8 +76,10 @@ class CalDAVClient { protected $requestMethod = "GET"; protected $httpRequest = ""; // for debugging http headers sent protected $xmlRequest = ""; // for debugging xml sent - protected $httpResponse = ""; // http headers received protected $xmlResponse = ""; // xml received + protected $httpResponseCode = 0; // http response code + protected $httpResponseHeaders = ""; + protected $httpResponseBody = ""; protected $parser; // our XML parser object @@ -167,11 +169,7 @@ class CalDAVClient { */ function ParseResponse( $response ) { $pos = strpos($response, 'httpResponse = trim($response); - } - else { - $this->httpResponse = trim(substr($response, 0, $pos)); + if ($pos !== false) { $this->xmlResponse = trim(substr($response, $pos)); $this->xmlResponse = preg_replace('{>[^>]*$}s', '>',$this->xmlResponse ); $parser = xml_parser_create_ns('UTF-8'); @@ -268,7 +266,6 @@ class CalDAVClient { $this->httpRequest = join("\r\n",$headers); $this->xmlRequest = $this->body; - $this->httpResponse = ''; $this->xmlResponse = ''; $fip = fsockopen( $this->protocol . '://' . $this->server, $this->port, $errno, $errstr, _FSOCK_TIMEOUT); //error handling? @@ -280,6 +277,7 @@ class CalDAVClient { list( $this->httpResponseHeaders, $this->httpResponseBody ) = preg_split( '{\r?\n\r?\n}s', $response, 2 ); if ( preg_match( '{Transfer-Encoding: chunked}i', $this->httpResponseHeaders ) ) $this->Unchunk(); + $this->httpResponseCode = intval(substr($this->httpResponseHeaders,0,3)); $this->headers = array(); // reset the headers array for our next request $this->ParseResponse($this->httpResponseBody); @@ -431,7 +429,7 @@ class CalDAVClient { $this->SetMatch( true, $etag ); } $this->DoRequest($url); - return $this->resultcode; + return $this->httpResponseCode; }