Skip to content

Commit

Permalink
#184 - using ClientBuilder in the HttpStatusCodeCheck.php
Browse files Browse the repository at this point in the history
  • Loading branch information
AloisJasa committed Apr 6, 2023
1 parent b4e4fdb commit 009853f
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions app/Check/Consumers/HttpStatusCodeCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 009853f

Please sign in to comment.