Add error message for missing/invalid header (#1017)
* add error message for missing/invalid header * Code cleanup - simplify the check - do not invert the result of `preg_match()` - do not set the `$result` in loop, it is already set after the loop - fix the order of code, first set `$this->error` then `$result`pull/979/head^2
parent
9c8ed81203
commit
88708240c7
|
@ -331,19 +331,19 @@ class StatusUpdater
|
|||
list ($key, $value) = explode(': ', $line);
|
||||
// Header found (case-insensitive)
|
||||
if (strcasecmp($key, $this->server['header_name']) == 0) {
|
||||
// The value doesn't match what we needed
|
||||
if (!preg_match("/{$this->server['header_value']}/i", $value)) {
|
||||
$result = false;
|
||||
} else {
|
||||
// The value matches what we need, everything is fine
|
||||
if (preg_match("/{$this->server['header_value']}/i", $value)) {
|
||||
$header_flag = true;
|
||||
break; // No need to go further
|
||||
break; // The correct header is found, we leave the loop
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$header_flag) {
|
||||
// Header was not present
|
||||
// Header was not present, set error message and $result variable
|
||||
$this->error = 'HEADER ERROR : Header "' . $this->server['header_name'] .
|
||||
'" not found or does not match "/' . $this->server['header_value'] . '/i".';
|
||||
$result = false;
|
||||
}
|
||||
}
|
||||
|
@ -447,7 +447,7 @@ class StatusUpdater
|
|||
socket_send($socket, $package, strLen($package), 0);
|
||||
// socket_read returns a string or false
|
||||
$status = socket_read($socket, 255) !== false ? true : false;
|
||||
|
||||
|
||||
if ($status) {
|
||||
$this->header = "Success.";
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue