From ccb6c8f38e5bb8fe7c525138adc07152e15b8cd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alois=20Ja=C5=A1a?= Date: Thu, 6 Apr 2023 13:24:05 +0200 Subject: [PATCH] #184 - using ClientBuilder in the HttpStatusCodeCheck.php --- app/Check/Consumers/HttpStatusCodeCheck.php | 23 +++++++-------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/app/Check/Consumers/HttpStatusCodeCheck.php b/app/Check/Consumers/HttpStatusCodeCheck.php index fef6595..5e9f473 100644 --- a/app/Check/Consumers/HttpStatusCodeCheck.php +++ b/app/Check/Consumers/HttpStatusCodeCheck.php @@ -14,24 +14,17 @@ class HttpStatusCodeCheck extends Check protected function doHardJob(\Pd\Monitoring\Check\Check $check): bool { try { - $config = [ - 'verify' => FALSE, - 'allow_redirects' => FALSE, - ]; - - $options = [ - 'connect_timeout' => self::TIMEOUT, - 'timeout' => 2 * self::TIMEOUT, - 'headers' => [ - 'User-Agent' => 'PeckaMonitoringBot/1.0', - ], - ]; - - $client = new \GuzzleHttp\Client($config); + + $client = \Pd\Monitoring\Check\Consumers\Client\ClientBuilder::create(2 * self::TIMEOUT, self::TIMEOUT) + ->withVerify(FALSE) + ->withAllowRedirects(\Pd\Monitoring\Check\Consumers\Client\Conf\AllowRedirects::create(FALSE)) + ->build() + ; + try { $this->logInfo($check, \sprintf('Kontrola ID "%s". Začínám stahovat url "%s".', $check->id, $check->url)); - $response = $client->get($check->url, $options); + $response = $client->get($check->url); $this->logHeaders($check, $response);