/** * @throws InvalidConfiguration */ public function runMonitor() { if (empty($this->url)) { throw InvalidConfiguration::noUrlConfigured(); } try { $guzzle = new Guzzle(['timeout' => $this->timeout, 'allow_redirects' => $this->allowRedirects]); $response = $guzzle->get($this->url); $this->responseCode = $response->getStatusCode(); $this->responseContent = (string) $response->getBody(); } catch (ClientException $e) { $response = $e->getResponse(); $this->responseCode = $response->getStatusCode(); } catch (ConnectException $e) { } if ($this->responseCode != '200' || !$this->checkResponseContains($this->responseContent, $this->checkPhrase)) { event(new HttpPingDown($this)); } else { event(new HttpPingUp($this)); } }
protected function parseUrl($url) { if (empty($url)) { throw InvalidConfiguration::noUrlConfigured(); } $urlParts = parse_url($url); if (!$urlParts) { throw InvalidConfiguration::urlCouldNotBeParsed(); } if (empty($urlParts['scheme']) || $urlParts['scheme'] != 'https') { throw InvalidConfiguration::urlNotSecure(); } return $urlParts; }