Refactor conditional logic for response handling

- Adjusted code to handle different scenarios when processing responses.
This commit is contained in:
Jeroen De Meerleer 2024-06-04 13:22:16 +02:00
parent 439d658d14
commit fd8a67c23c
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6

View File

@ -47,9 +47,17 @@ if(php_sapi_name() == 'cli' || $_SERVER["REQUEST_URI"] == '/metrics') {
}
if (isset($submetric['http']['data']) && $submetric['http']['data'] == 'responsebody') {
$output = $res->getBody()->getContents();
if ($hasresponse) {
$output = $res->getBody()->getContents();
} else {
$output = '';
}
} elseif ((isset($submetric['http']['statuscode'])) && (isset($submetric['http']['data']) && $submetric['http']['data'] == 'hasresponse')) {
$output = (int)in_array($res->getStatusCode(), $submetric['http']['statuscode']);
if ($hasresponse) {
$output = $output = (int)in_array($res->getStatusCode(), $submetric['http']['statuscode']);;
} else {
$output = 0;
}
} elseif (isset($submetric['http']['data']) && $submetric['http']['data'] == 'hasresponse') {
$output = (int)$hasresponse;
}