From c88a2fbec2f85b2e3c353968459c441b52429cf5 Mon Sep 17 00:00:00 2001 From: Mike Dilger Date: Wed, 12 Nov 2014 13:35:38 +1300 Subject: [PATCH] Tolerate HTTP status code line followed by zero header lines --- src/Httpful/Response.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Httpful/Response.php b/src/Httpful/Response.php index 9e12fcf..9a0e7cf 100644 --- a/src/Httpful/Response.php +++ b/src/Httpful/Response.php @@ -136,7 +136,9 @@ public function _parseHeaders($headers) public function _parseCode($headers) { - $parts = explode(' ', substr($headers, 0, strpos($headers, "\r\n"))); + $end = strpos($headers, "\r\n"); + if ($end === false) $end = strlen($headers); + $parts = explode(' ', substr($headers, 0, $end)); if (count($parts) < 2 || !is_numeric($parts[1])) { throw new \Exception("Unable to parse response code from HTTP response due to malformed response"); }