Skip to content

Commit

Permalink
Merge pull request #156 from mikedilger/zero_headers
Browse files Browse the repository at this point in the history
Tolerate HTTP status code line followed by zero header lines
  • Loading branch information
Nate Good committed Dec 19, 2014
2 parents 41bc3e2 + c88a2fb commit 6c0d64a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Httpful/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down

0 comments on commit 6c0d64a

Please sign in to comment.