From 9ff16853b29f6fb70e3182c6ffc55fcb9a547eb4 Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Wed, 4 Apr 2012 23:15:22 +1200 Subject: [PATCH] Properly calculate response code. --- inc/caldav-client-v2.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/inc/caldav-client-v2.php b/inc/caldav-client-v2.php index 3547bb2e..152624c7 100644 --- a/inc/caldav-client-v2.php +++ b/inc/caldav-client-v2.php @@ -277,7 +277,10 @@ 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)); + if ( preg_match('/HTTP\/\d\.\d (\d{3})/', $this->httpResponseHeaders, $status) ) + $this->httpResponseCode = intval($status); + else + $this->httpResponseCode = 0; $this->headers = array(); // reset the headers array for our next request $this->ParseResponse($this->httpResponseBody); -- 2.11.4.GIT