Move "getUserAgent()" to "HTTPRequest" class
This commit is contained in:
parent
cebdcb6599
commit
57587efe58
16
src/App.php
16
src/App.php
|
@ -240,22 +240,6 @@ class App
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the current UserAgent as a String
|
|
||||||
*
|
|
||||||
* @return string the UserAgent as a String
|
|
||||||
* @throws HTTPException\InternalServerErrorException
|
|
||||||
*/
|
|
||||||
public function getUserAgent()
|
|
||||||
{
|
|
||||||
return
|
|
||||||
FRIENDICA_PLATFORM . " '" .
|
|
||||||
FRIENDICA_CODENAME . "' " .
|
|
||||||
FRIENDICA_VERSION . '-' .
|
|
||||||
DB_UPDATE_VERSION . '; ' .
|
|
||||||
$this->baseURL->get();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current theme name. May be overriden by the mobile theme name.
|
* Returns the current theme name. May be overriden by the mobile theme name.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1094,7 +1094,7 @@ class BBCode
|
||||||
$ch = @curl_init($match[1]);
|
$ch = @curl_init($match[1]);
|
||||||
@curl_setopt($ch, CURLOPT_NOBODY, true);
|
@curl_setopt($ch, CURLOPT_NOBODY, true);
|
||||||
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
@curl_setopt($ch, CURLOPT_USERAGENT, $a->getUserAgent());
|
@curl_setopt($ch, CURLOPT_USERAGENT, DI::httpRequest()->getUserAgent());
|
||||||
@curl_exec($ch);
|
@curl_exec($ch);
|
||||||
$curl_info = @curl_getinfo($ch);
|
$curl_info = @curl_getinfo($ch);
|
||||||
|
|
||||||
|
@ -1168,7 +1168,7 @@ class BBCode
|
||||||
$ch = @curl_init($match[1]);
|
$ch = @curl_init($match[1]);
|
||||||
@curl_setopt($ch, CURLOPT_NOBODY, true);
|
@curl_setopt($ch, CURLOPT_NOBODY, true);
|
||||||
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
@curl_setopt($ch, CURLOPT_USERAGENT, $a->getUserAgent());
|
@curl_setopt($ch, CURLOPT_USERAGENT, DI::httpRequest()->getUserAgent());
|
||||||
@curl_exec($ch);
|
@curl_exec($ch);
|
||||||
$curl_info = @curl_getinfo($ch);
|
$curl_info = @curl_getinfo($ch);
|
||||||
|
|
||||||
|
|
|
@ -41,14 +41,14 @@ class HTTPRequest
|
||||||
/** @var IConfig */
|
/** @var IConfig */
|
||||||
private $config;
|
private $config;
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private $userAgent;
|
private $baseUrl;
|
||||||
|
|
||||||
public function __construct(LoggerInterface $logger, Profiler $profiler, IConfig $config, App $a)
|
public function __construct(LoggerInterface $logger, Profiler $profiler, IConfig $config, App\BaseURL $baseUrl)
|
||||||
{
|
{
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
$this->profiler = $profiler;
|
$this->profiler = $profiler;
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->userAgent = $a->getUserAgent();
|
$this->baseUrl = $baseUrl->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -378,4 +378,19 @@ class HTTPRequest
|
||||||
$redirects
|
$redirects
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current UserAgent as a String
|
||||||
|
*
|
||||||
|
* @return string the UserAgent as a String
|
||||||
|
*/
|
||||||
|
public function getUserAgent()
|
||||||
|
{
|
||||||
|
return
|
||||||
|
FRIENDICA_PLATFORM . " '" .
|
||||||
|
FRIENDICA_CODENAME . "' " .
|
||||||
|
FRIENDICA_VERSION . '-' .
|
||||||
|
DB_UPDATE_VERSION . '; ' .
|
||||||
|
$this->baseUrl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -350,7 +350,7 @@ class Network
|
||||||
curl_setopt($ch, CURLOPT_NOBODY, 1);
|
curl_setopt($ch, CURLOPT_NOBODY, 1);
|
||||||
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
curl_setopt($ch, CURLOPT_USERAGENT, $a->getUserAgent());
|
curl_setopt($ch, CURLOPT_USERAGENT, DI::httpRequest()->getUserAgent());
|
||||||
|
|
||||||
curl_exec($ch);
|
curl_exec($ch);
|
||||||
$curl_info = @curl_getinfo($ch);
|
$curl_info = @curl_getinfo($ch);
|
||||||
|
@ -394,7 +394,7 @@ class Network
|
||||||
curl_setopt($ch, CURLOPT_NOBODY, 0);
|
curl_setopt($ch, CURLOPT_NOBODY, 0);
|
||||||
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
curl_setopt($ch, CURLOPT_USERAGENT, $a->getUserAgent());
|
curl_setopt($ch, CURLOPT_USERAGENT, DI::httpRequest()->getUserAgent());
|
||||||
|
|
||||||
$body = curl_exec($ch);
|
$body = curl_exec($ch);
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user