From a777a0f0e55b96add941661abd17fecba57287e8 Mon Sep 17 00:00:00 2001 From: Bobemoe Date: Fri, 4 Dec 2020 09:57:42 +0000 Subject: [PATCH] use final http ststus code after redirects, not initial code --- src/psm/Util/Server/Updater/StatusUpdater.php | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/psm/Util/Server/Updater/StatusUpdater.php b/src/psm/Util/Server/Updater/StatusUpdater.php index 6d6ff34b..e7479dc4 100644 --- a/src/psm/Util/Server/Updater/StatusUpdater.php +++ b/src/psm/Util/Server/Updater/StatusUpdater.php @@ -283,25 +283,16 @@ class StatusUpdater $this->rtime = (microtime(true) - $starttime); // the first line would be the status code.. - $status_code = strtok($curl_result['exec'], "\r\n"); - // keep it general - // $code[2][0] = status code - // $code[3][0] = name of status code - $code_matches = array(); - preg_match_all("/[A-Z]{2,5}\/\d(\.\d)?\s(\d{3})\s?(.*)/", $status_code, $code_matches); - - if (empty($code_matches[0])) { + $code = $curl_result['info']['http_code']; + if (empty($code)) { // somehow we dont have a proper response. $this->error = 'TIMEOUT ERROR: no response from server'; $result = false; } else { - $code = $code_matches[2][0]; - $msg = $code_matches[3][0]; - $allow_http_status = explode("|", $this->server['allow_http_status']); // All status codes starting with a 4 or higher mean trouble! if (substr($code, 0, 1) >= '4' && !in_array($code, $allow_http_status)) { - $this->error = "HTTP STATUS ERROR: " . $code . ' ' . $msg; + $this->error = "HTTP STATUS ERROR: " . $code; $result = false; } else { $result = true;