commit
c41ce95f4e
3 changed files with 9 additions and 2 deletions
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
namespace Friendica\Directory\Pollers;
|
namespace Friendica\Directory\Pollers;
|
||||||
|
|
||||||
|
use Friendica\Directory\Utils\Network;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Hypolite Petovan <hypolite@mrpetovan.com>
|
* @author Hypolite Petovan <hypolite@mrpetovan.com>
|
||||||
*/
|
*/
|
||||||
|
@ -96,7 +98,7 @@ class Directory
|
||||||
CURLOPT_SSL_VERIFYHOST => 2,
|
CURLOPT_SSL_VERIFYHOST => 2,
|
||||||
CURLOPT_PROTOCOLS => CURLPROTO_HTTP | CURLPROTO_HTTPS,
|
CURLOPT_PROTOCOLS => CURLPROTO_HTTP | CURLPROTO_HTTPS,
|
||||||
//Basic request
|
//Basic request
|
||||||
CURLOPT_USERAGENT => 'friendica-directory-probe-1.0',
|
CURLOPT_USERAGENT => Network::USER_AGENT,
|
||||||
CURLOPT_RETURNTRANSFER => true,
|
CURLOPT_RETURNTRANSFER => true,
|
||||||
CURLOPT_URL => $directory_url . $path
|
CURLOPT_URL => $directory_url . $path
|
||||||
);
|
);
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
namespace Friendica\Directory\Pollers;
|
namespace Friendica\Directory\Pollers;
|
||||||
|
|
||||||
use ByJG\Util\WebRequest;
|
use ByJG\Util\WebRequest;
|
||||||
|
use Friendica\Directory\Utils\Network;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Hypolite Petovan <hypolite@mrpetovan.com>
|
* @author Hypolite Petovan <hypolite@mrpetovan.com>
|
||||||
|
@ -244,7 +245,7 @@ class Server
|
||||||
CURLOPT_SSL_VERIFYHOST => 2,
|
CURLOPT_SSL_VERIFYHOST => 2,
|
||||||
CURLOPT_PROTOCOLS => CURLPROTO_HTTP | CURLPROTO_HTTPS,
|
CURLOPT_PROTOCOLS => CURLPROTO_HTTP | CURLPROTO_HTTPS,
|
||||||
//Basic request
|
//Basic request
|
||||||
CURLOPT_USERAGENT => 'friendica-directory-probe-1.0',
|
CURLOPT_USERAGENT => Network::USER_AGENT,
|
||||||
CURLOPT_RETURNTRANSFER => true,
|
CURLOPT_RETURNTRANSFER => true,
|
||||||
CURLOPT_URL => $base_url . '/friendica/json'
|
CURLOPT_URL => $base_url . '/friendica/json'
|
||||||
);
|
);
|
||||||
|
|
|
@ -15,6 +15,8 @@ namespace Friendica\Directory\Utils;
|
||||||
*/
|
*/
|
||||||
class Network
|
class Network
|
||||||
{
|
{
|
||||||
|
const USER_AGENT = 'friendica-directory-probe-1.0';
|
||||||
|
|
||||||
public static function fetchURL(string $url, bool $binary = false, int $timeout = 20): string
|
public static function fetchURL(string $url, bool $binary = false, int $timeout = 20): string
|
||||||
{
|
{
|
||||||
$ch = curl_init($url);
|
$ch = curl_init($url);
|
||||||
|
@ -27,6 +29,7 @@ class Network
|
||||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||||
curl_setopt($ch, CURLOPT_MAXREDIRS, 8);
|
curl_setopt($ch, CURLOPT_MAXREDIRS, 8);
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
curl_setopt($ch, CURLOPT_USERAGENT, self::USER_AGENT);
|
||||||
if ($binary) {
|
if ($binary) {
|
||||||
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
|
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
|
||||||
}
|
}
|
||||||
|
@ -49,6 +52,7 @@ class Network
|
||||||
curl_setopt($ch, CURLOPT_MAXREDIRS , 8);
|
curl_setopt($ch, CURLOPT_MAXREDIRS , 8);
|
||||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
|
||||||
curl_setopt($ch, CURLOPT_NOBODY , true);
|
curl_setopt($ch, CURLOPT_NOBODY , true);
|
||||||
|
curl_setopt($ch, CURLOPT_USERAGENT , self::USER_AGENT);
|
||||||
|
|
||||||
curl_exec($ch);
|
curl_exec($ch);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue