From c504709074188ba42f8a8f3e0c5c2a42cc74cf3d Mon Sep 17 00:00:00 2001 From: Thomas Casteleyn Date: Wed, 10 Jul 2024 10:35:12 +0200 Subject: [PATCH 1/2] Correctly identify as iTop in cURL requests --- application/utils.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/utils.inc.php b/application/utils.inc.php index 9a7528fd1e..65b9bbff31 100644 --- a/application/utils.inc.php +++ b/application/utils.inc.php @@ -1929,7 +1929,7 @@ public static function DoPostRequest($sUrl, $aData, $sOptionnalHeaders = null, & CURLOPT_HEADER => false, // don't return the headers in the output CURLOPT_FOLLOWLOCATION => true, // follow redirects CURLOPT_ENCODING => "", // handle all encodings - CURLOPT_USERAGENT => "spider", // who am i + CURLOPT_USERAGENT => ITOP_APPLICATION.'/'.ITOP_VERSION, // who am i CURLOPT_AUTOREFERER => true, // set referer on redirect CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect CURLOPT_TIMEOUT => 120, // timeout on response From 62c475407281b6195e0bbe12601241d4457c9abf Mon Sep 17 00:00:00 2001 From: Thomas Casteleyn Date: Mon, 9 Sep 2024 10:02:01 +0200 Subject: [PATCH 2/2] Use configuration option to set custom user agent --- application/utils.inc.php | 2 +- core/config.class.inc.php | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/application/utils.inc.php b/application/utils.inc.php index 65b9bbff31..45293b322a 100644 --- a/application/utils.inc.php +++ b/application/utils.inc.php @@ -1929,7 +1929,7 @@ public static function DoPostRequest($sUrl, $aData, $sOptionnalHeaders = null, & CURLOPT_HEADER => false, // don't return the headers in the output CURLOPT_FOLLOWLOCATION => true, // follow redirects CURLOPT_ENCODING => "", // handle all encodings - CURLOPT_USERAGENT => ITOP_APPLICATION.'/'.ITOP_VERSION, // who am i + CURLOPT_USERAGENT => static::GetConfig()->Get('http.request.user_agent'), // who am i CURLOPT_AUTOREFERER => true, // set referer on redirect CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect CURLOPT_TIMEOUT => 120, // timeout on response diff --git a/core/config.class.inc.php b/core/config.class.inc.php index 6fb2d6ea80..769beb83f5 100644 --- a/core/config.class.inc.php +++ b/core/config.class.inc.php @@ -1787,6 +1787,13 @@ class Config 'source_of_value' => '', 'show_in_conf_sample' => false, ], + 'http.request.user_agent' => [ + 'type' => 'string', + 'description' => 'HTTP request user agent, use this to set a custom agent on external requests.', + 'default' => ITOP_APPLICATION.'/'.ITOP_VERSION, + 'source_of_value' => '', + 'show_in_conf_sample' => false, + ] ]; public function IsProperty($sPropCode)