Skip to content
Permalink
Browse files

* Added timeout options to the CURL manager. (Class-WebGet.php)

  • Loading branch information...
Nao committed May 23, 2018
1 parent 1ecc209 commit 18c6ad06a4d1f10e96519740eb5811ca6aafa606
Showing with 13 additions and 3 deletions.
  1. +13 −3 core/app/Class-WebGet.php
@@ -148,6 +148,8 @@ private function getCurl()
curl_setopt($curl, CURLOPT_USERAGENT, $this->user_agent); // User agent to supply
curl_setopt($curl, CURLOPT_HEADER, false); // We don't want the header in the output
curl_setopt($curl, CURLOPT_NOBODY, false); // But we DO want the body
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
// Secure connections require a little more work
if ($this->secure)
@@ -179,10 +181,18 @@ private function getCurl()
curl_setopt($curl, CURLOPT_USERPWD, 'anonymous:' . $webmaster_email);
$data = curl_exec($curl);
curl_close($curl);
if ($data === false)
$data = file_get_contents($this->url);
{
$curl_info = curl_getinfo($curl);
curl_close($curl);
$curl_failed = true;
if ($curl_info['http_code'] == 404)
return 'Error 404';
if ($curl_info['http_code'] >= 300)
$data = file_get_contents($this->url, false, stream_context_create(['http' => ['timeout' => 30]]));
}
else
curl_close($curl);
return $data;
}

0 comments on commit 18c6ad0

Please sign in to comment.
You can’t perform that action at this time.