diff --git a/lib/ConsumerStrategies/SocketConsumer.php b/lib/ConsumerStrategies/SocketConsumer.php index 9ee07f6..8e881c3 100644 --- a/lib/ConsumerStrategies/SocketConsumer.php +++ b/lib/ConsumerStrategies/SocketConsumer.php @@ -286,9 +286,13 @@ private function handleResponse($response) { } - // extract status - $line_one_exploded = explode(" ", $lines[0]); - $status = $line_one_exploded[1]; + // extract status + $line_one_exploded = explode(" ", $lines[0]); + if ($line_one_exploded === false || ! isset($line_one_exploded[1])) { + $status = "Unable to extract HTTP status from response"; + } else { + $status = $line_one_exploded[1]; + } // extract body $body = $lines[count($lines) - 1]; @@ -301,12 +305,10 @@ private function handleResponse($response) { } } - $ret = array( - "status" => $status, - "body" => $body, + return array( + "status" => $status, + "body" => $body, ); - - return $ret; }