Add custom header to StatusUpdater

This commit is contained in:
Hubert Moreau 2022-08-15 10:43:44 +02:00
parent 83813f92ea
commit 0291f8f3cd
2 changed files with 10 additions and 3 deletions

View File

@ -390,6 +390,7 @@ namespace {
* @param string|bool $website_password Password website
* @param string|null $request_method Request method like GET, POST etc.
* @param string|null $post_field POST data
* @param string|null $custom_header HEADER data
* @return array cURL result
*/
function psm_curl_get(
@ -401,7 +402,8 @@ namespace {
$website_username = false,
$website_password = false,
$request_method = null,
$post_field = null
$post_field = null,
$custom_header = null
) {
($timeout === null || $timeout > 0) ? PSM_CURL_TIMEOUT : intval($timeout);
@ -429,6 +431,10 @@ namespace {
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_field);
}
if (!empty($custom_header)){
curl_setopt($ch, CURLOPT_HTTPHEADER, array($custom_header));
}
if (
$website_username !== false &&
$website_password !== false &&

View File

@ -100,7 +100,7 @@ class StatusUpdater
'allow_http_status', 'redirect_check', 'header_name',
'header_value', 'status', 'active', 'warning_threshold',
'warning_threshold_counter', 'ssl_cert_expiry_days', 'ssl_cert_expired_time', 'timeout', 'website_username',
'website_password', 'last_offline'
'website_password', 'last_offline', 'custom_header'
));
if (empty($this->server)) {
return false;
@ -248,7 +248,8 @@ class StatusUpdater
psm_password_decrypt($this->server['server_id'] .
psm_get_conf('password_encrypt_key'), $this->server['website_password']),
$this->server['request_method'],
$this->server['post_field']
$this->server['post_field'],
$this->server['custom_header']
);
$this->header = $curl_result['exec'];
$this->curl_info = $curl_result['info'];