Request type set for all HTTP requests

This commit is contained in:
Michael 2024-05-12 17:53:21 +00:00
parent d788cb82cc
commit 5751e024c0
30 changed files with 129 additions and 90 deletions

View file

@ -26,6 +26,7 @@ use Friendica\Core\Logger;
use Friendica\DI;
use Friendica\Model\Photo;
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
use Friendica\Network\HTTPClient\Client\HttpClientRequest;
use Friendica\Object\Image;
/**
@ -356,7 +357,7 @@ class Images
if (empty($img_str)) {
try {
$img_str = DI::httpClient()->fetch($url, HttpClientAccept::IMAGE, 4);
$img_str = DI::httpClient()->fetch($url, HttpClientAccept::IMAGE, 4, '', HttpClientRequest::MEDIAVERIFIER);
} catch (\Exception $exception) {
Logger::notice('Image is invalid', ['url' => $url, 'exception' => $exception]);
return [];

View file

@ -80,7 +80,7 @@ class Network
if (in_array(parse_url($url, PHP_URL_SCHEME), ['https', 'http'])) {
$options = [HttpClientOptions::VERIFY => true, HttpClientOptions::TIMEOUT => $xrd_timeout,
HttpClientOptions::REQUEST => HttpClientRequest::VERIFIER];
HttpClientOptions::REQUEST => HttpClientRequest::URLVERIFIER];
try {
$curlResult = DI::httpClient()->head($url, $options);
} catch (\Exception $e) {

View file

@ -234,7 +234,7 @@ class ParseUrl
}
try {
$curlResult = DI::httpClient()->get($url, HttpClientAccept::HTML, [HttpClientOptions::CONTENT_LENGTH => 1000000]);
$curlResult = DI::httpClient()->get($url, HttpClientAccept::HTML, [HttpClientOptions::CONTENT_LENGTH => 1000000, HttpClientOptions::REQUEST => HttpClientRequest::SITEINFO]);
} catch (\Throwable $th) {
Logger::info('Exception when fetching', ['url' => $url, 'code' => $th->getCode(), 'message' => $th->getMessage()]);
return $siteinfo;