diff --git a/lib/Cake/Network/Http/HttpSocketResponse.php b/lib/Cake/Network/Http/HttpSocketResponse.php index b20e0643b..4e62fa340 100644 --- a/lib/Cake/Network/Http/HttpSocketResponse.php +++ b/lib/Cake/Network/Http/HttpSocketResponse.php @@ -159,10 +159,12 @@ class HttpSocketResponse implements ArrayAccess { $this->raw = $message; $this->body = (string)substr($message, strlen($match[0])); - if (preg_match("/(.+) ([0-9]{3})\s*([^ ]*)\r\n/DU", $statusLine, $match)) { + if (preg_match("/(.+) ([0-9]{3})(?:\s+(\w.+))?\s*\r\n/DU", $statusLine, $match)) { $this->httpVersion = $match[1]; $this->code = $match[2]; - $this->reasonPhrase = $match[3]; + if (isset($match[3])) { + $this->reasonPhrase = $match[3]; + } } $this->headers = $this->_parseHeader($header); diff --git a/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php b/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php index cc86d7ba3..6095e5de0 100644 --- a/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php +++ b/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php @@ -1762,10 +1762,12 @@ class HttpSocketTest extends CakeTestCase { */ public function statusProvider() { return array( - array('HTTP/1.1 200 '), - array('HTTP/1.1 200 '), - array('HTTP/1.1 200'), - array('HTTP/1.1 200 OK', 'OK'), + array('HTTP/1.1 200 ', '200'), + array('HTTP/1.1 200 ', '200'), + array('HTTP/1.1 200', '200'), + array('HTTP/1.1 200 OK', '200', 'OK'), + array('HTTP/1.1 404 Not Found', '404', 'Not Found'), + array('HTTP/1.1 404 Not Found', '404', 'Not Found'), ); } @@ -1775,7 +1777,7 @@ class HttpSocketTest extends CakeTestCase { * @dataProvider statusProvider * @return void */ - public function testResponseStatusParsing($status, $msg = '') { + public function testResponseStatusParsing($status, $code, $msg = '') { $this->Socket->connected = true; $serverResponse = $status . "\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\n\r\n