diff --git a/index.php b/index.php index 1310042..92aa467 100644 --- a/index.php +++ b/index.php @@ -22,11 +22,19 @@ if($_SERVER["REQUEST_URI"] == '/metrics' || php_sapi_name() == 'cli') { $output = $stats->getTransferTime(); }; } - - $res = $client->request('GET', $c['http']['url'], $options); + + $hasresponse = NULL; + try{ + $res = $client->request('GET', $c['http']['url'], $options); + $hasresponse = true; + } catch(GuzzleHttp\Exception\GuzzleException $e) { + $hasresponse = false; + } if (isset($c['http']['data']) && $c['http']['data'] == 'responsebody') { $output = $res->getBody()->getContents(); + } elseif (isset($c['http']['data']) && $c['http']['data'] == 'hasresponse') { + $output = (int)$hasresponse; } }