mirror of
https://github.com/friendica/friendica
synced 2025-04-27 18:30:12 +00:00
Move ACCEPT constants to own "enum" class
This commit is contained in:
parent
c700645385
commit
73c3b21665
35 changed files with 144 additions and 138 deletions
|
@ -28,7 +28,7 @@ use Friendica\Core\System;
|
|||
use Friendica\Database\DBA;
|
||||
use Friendica\Database\DBStructure;
|
||||
use Friendica\DI;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClient;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Network\Probe;
|
||||
use Friendica\Protocol\ActivityNamespace;
|
||||
|
@ -72,10 +72,10 @@ class APContact
|
|||
|
||||
$data = ['addr' => $addr];
|
||||
$template = 'https://' . $addr_parts[1] . '/.well-known/webfinger?resource=acct:' . urlencode($addr);
|
||||
$webfinger = Probe::webfinger(str_replace('{uri}', urlencode($addr), $template), HttpClient::ACCEPT_JRD_JSON);
|
||||
$webfinger = Probe::webfinger(str_replace('{uri}', urlencode($addr), $template), HttpClientAccept::JRD_JSON);
|
||||
if (empty($webfinger['links'])) {
|
||||
$template = 'http://' . $addr_parts[1] . '/.well-known/webfinger?resource=acct:' . urlencode($addr);
|
||||
$webfinger = Probe::webfinger(str_replace('{uri}', urlencode($addr), $template), HttpClient::ACCEPT_JRD_JSON);
|
||||
$webfinger = Probe::webfinger(str_replace('{uri}', urlencode($addr), $template), HttpClientAccept::JRD_JSON);
|
||||
if (empty($webfinger['links'])) {
|
||||
return [];
|
||||
}
|
||||
|
|
|
@ -32,9 +32,9 @@ use Friendica\Database\Database;
|
|||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\Register;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientOptions;
|
||||
use Friendica\Network\HTTPClient\Capability\ICanHandleHttpResponses;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClient;
|
||||
use Friendica\Protocol\Relay;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Network;
|
||||
|
@ -344,7 +344,7 @@ class GServer
|
|||
|
||||
// When a nodeinfo is present, we don't need to dig further
|
||||
$xrd_timeout = DI::config()->get('system', 'xrd_timeout');
|
||||
$curlResult = DI::httpClient()->get($url . '/.well-known/nodeinfo', [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
|
||||
$curlResult = DI::httpClient()->get($url . '/.well-known/nodeinfo', [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
|
||||
if ($curlResult->isTimeout()) {
|
||||
self::setFailure($url);
|
||||
return false;
|
||||
|
@ -352,7 +352,7 @@ class GServer
|
|||
|
||||
// On a redirect follow the new host but mark the old one as failure
|
||||
if ($curlResult->isSuccess() && !empty($curlResult->getRedirectUrl()) && (parse_url($url, PHP_URL_HOST) != parse_url($curlResult->getRedirectUrl(), PHP_URL_HOST))) {
|
||||
$curlResult = DI::httpClient()->get($url, [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_HTML]);
|
||||
$curlResult = DI::httpClient()->get($url, [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::HTML]);
|
||||
if (!empty($curlResult->getRedirectUrl()) && parse_url($url, PHP_URL_HOST) != parse_url($curlResult->getRedirectUrl(), PHP_URL_HOST)) {
|
||||
Logger::info('Found redirect. Mark old entry as failure', ['old' => $url, 'new' => $curlResult->getRedirectUrl()]);
|
||||
self::setFailure($url);
|
||||
|
@ -394,7 +394,7 @@ class GServer
|
|||
$basedata = ['detection-method' => self::DETECT_MANUAL];
|
||||
}
|
||||
|
||||
$curlResult = DI::httpClient()->get($baseurl, [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_HTML]);
|
||||
$curlResult = DI::httpClient()->get($baseurl, [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::HTML]);
|
||||
if ($curlResult->isSuccess()) {
|
||||
if (!empty($curlResult->getRedirectUrl()) && (parse_url($baseurl, PHP_URL_HOST) != parse_url($curlResult->getRedirectUrl(), PHP_URL_HOST))) {
|
||||
Logger::info('Found redirect. Mark old entry as failure', ['old' => $url, 'new' => $curlResult->getRedirectUrl()]);
|
||||
|
@ -418,7 +418,7 @@ class GServer
|
|||
// When the base path doesn't seem to contain a social network we try the complete path.
|
||||
// Most detectable system have to be installed in the root directory.
|
||||
// We checked the base to avoid false positives.
|
||||
$curlResult = DI::httpClient()->get($url, [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_HTML]);
|
||||
$curlResult = DI::httpClient()->get($url, [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::HTML]);
|
||||
if ($curlResult->isSuccess()) {
|
||||
$urldata = self::analyseRootHeader($curlResult, $serverdata);
|
||||
$urldata = self::analyseRootBody($curlResult, $urldata, $url);
|
||||
|
@ -588,7 +588,7 @@ class GServer
|
|||
{
|
||||
Logger::info('Discover relay data', ['server' => $server_url]);
|
||||
|
||||
$curlResult = DI::httpClient()->get($server_url . '/.well-known/x-social-relay', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
|
||||
$curlResult = DI::httpClient()->get($server_url . '/.well-known/x-social-relay', [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
|
||||
if (!$curlResult->isSuccess()) {
|
||||
return;
|
||||
}
|
||||
|
@ -683,7 +683,7 @@ class GServer
|
|||
*/
|
||||
private static function fetchStatistics(string $url)
|
||||
{
|
||||
$curlResult = DI::httpClient()->get($url . '/statistics.json', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
|
||||
$curlResult = DI::httpClient()->get($url . '/statistics.json', [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
|
||||
if (!$curlResult->isSuccess()) {
|
||||
return [];
|
||||
}
|
||||
|
@ -809,7 +809,7 @@ class GServer
|
|||
*/
|
||||
private static function parseNodeinfo1(string $nodeinfo_url)
|
||||
{
|
||||
$curlResult = DI::httpClient()->get($nodeinfo_url, [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
|
||||
$curlResult = DI::httpClient()->get($nodeinfo_url, [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
|
||||
if (!$curlResult->isSuccess()) {
|
||||
return [];
|
||||
}
|
||||
|
@ -902,7 +902,7 @@ class GServer
|
|||
*/
|
||||
private static function parseNodeinfo2(string $nodeinfo_url)
|
||||
{
|
||||
$curlResult = DI::httpClient()->get($nodeinfo_url, [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
|
||||
$curlResult = DI::httpClient()->get($nodeinfo_url, [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
|
||||
if (!$curlResult->isSuccess()) {
|
||||
return [];
|
||||
}
|
||||
|
@ -997,7 +997,7 @@ class GServer
|
|||
*/
|
||||
private static function fetchSiteinfo(string $url, array $serverdata)
|
||||
{
|
||||
$curlResult = DI::httpClient()->get($url . '/siteinfo.json', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
|
||||
$curlResult = DI::httpClient()->get($url . '/siteinfo.json', [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
|
||||
if (!$curlResult->isSuccess()) {
|
||||
return $serverdata;
|
||||
}
|
||||
|
@ -1082,7 +1082,7 @@ class GServer
|
|||
private static function validHostMeta(string $url)
|
||||
{
|
||||
$xrd_timeout = DI::config()->get('system', 'xrd_timeout');
|
||||
$curlResult = DI::httpClient()->get($url . '/.well-known/host-meta', [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_XRD_XML]);
|
||||
$curlResult = DI::httpClient()->get($url . '/.well-known/host-meta', [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::XRD_XML]);
|
||||
if (!$curlResult->isSuccess()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1174,7 +1174,7 @@ class GServer
|
|||
{
|
||||
$serverdata['poco'] = '';
|
||||
|
||||
$curlResult = DI::httpClient()->get($url . '/poco', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
|
||||
$curlResult = DI::httpClient()->get($url . '/poco', [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
|
||||
if (!$curlResult->isSuccess()) {
|
||||
return $serverdata;
|
||||
}
|
||||
|
@ -1204,7 +1204,7 @@ class GServer
|
|||
*/
|
||||
public static function checkMastodonDirectory(string $url, array $serverdata)
|
||||
{
|
||||
$curlResult = DI::httpClient()->get($url . '/api/v1/directory?limit=1', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
|
||||
$curlResult = DI::httpClient()->get($url . '/api/v1/directory?limit=1', [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
|
||||
if (!$curlResult->isSuccess()) {
|
||||
return $serverdata;
|
||||
}
|
||||
|
@ -1231,7 +1231,7 @@ class GServer
|
|||
*/
|
||||
private static function detectPeertube(string $url, array $serverdata)
|
||||
{
|
||||
$curlResult = DI::httpClient()->get($url . '/api/v1/config', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
|
||||
$curlResult = DI::httpClient()->get($url . '/api/v1/config', [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
|
||||
if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) {
|
||||
return $serverdata;
|
||||
}
|
||||
|
@ -1278,7 +1278,7 @@ class GServer
|
|||
*/
|
||||
private static function detectNextcloud(string $url, array $serverdata)
|
||||
{
|
||||
$curlResult = DI::httpClient()->get($url . '/status.php', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
|
||||
$curlResult = DI::httpClient()->get($url . '/status.php', [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
|
||||
if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) {
|
||||
return $serverdata;
|
||||
}
|
||||
|
@ -1302,7 +1302,7 @@ class GServer
|
|||
}
|
||||
|
||||
private static function fetchWeeklyUsage(string $url, array $serverdata) {
|
||||
$curlResult = DI::httpClient()->get($url . '/api/v1/instance/activity', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
|
||||
$curlResult = DI::httpClient()->get($url . '/api/v1/instance/activity', [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
|
||||
if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) {
|
||||
return $serverdata;
|
||||
}
|
||||
|
@ -1370,7 +1370,7 @@ class GServer
|
|||
*/
|
||||
private static function detectMastodonAlikes(string $url, array $serverdata)
|
||||
{
|
||||
$curlResult = DI::httpClient()->get($url . '/api/v1/instance', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
|
||||
$curlResult = DI::httpClient()->get($url . '/api/v1/instance', [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
|
||||
if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) {
|
||||
return $serverdata;
|
||||
}
|
||||
|
@ -1435,7 +1435,7 @@ class GServer
|
|||
*/
|
||||
private static function detectHubzilla(string $url, array $serverdata)
|
||||
{
|
||||
$curlResult = DI::httpClient()->get($url . '/api/statusnet/config.json', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
|
||||
$curlResult = DI::httpClient()->get($url . '/api/statusnet/config.json', [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
|
||||
if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) {
|
||||
return $serverdata;
|
||||
}
|
||||
|
@ -1532,7 +1532,7 @@ class GServer
|
|||
*/
|
||||
private static function detectPumpIO(string $url, array $serverdata)
|
||||
{
|
||||
$curlResult = DI::httpClient()->get($url . '/.well-known/host-meta.json', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
|
||||
$curlResult = DI::httpClient()->get($url . '/.well-known/host-meta.json', [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
|
||||
if (!$curlResult->isSuccess()) {
|
||||
return $serverdata;
|
||||
}
|
||||
|
@ -1583,7 +1583,7 @@ class GServer
|
|||
private static function detectGNUSocial(string $url, array $serverdata)
|
||||
{
|
||||
// Test for GNU Social
|
||||
$curlResult = DI::httpClient()->get($url . '/api/gnusocial/version.json', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
|
||||
$curlResult = DI::httpClient()->get($url . '/api/gnusocial/version.json', [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
|
||||
if ($curlResult->isSuccess() && ($curlResult->getBody() != '{"error":"not implemented"}') &&
|
||||
($curlResult->getBody() != '') && (strlen($curlResult->getBody()) < 30)) {
|
||||
$serverdata['platform'] = 'gnusocial';
|
||||
|
@ -1601,7 +1601,7 @@ class GServer
|
|||
}
|
||||
|
||||
// Test for Statusnet
|
||||
$curlResult = DI::httpClient()->get($url . '/api/statusnet/version.json', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
|
||||
$curlResult = DI::httpClient()->get($url . '/api/statusnet/version.json', [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
|
||||
if ($curlResult->isSuccess() && ($curlResult->getBody() != '{"error":"not implemented"}') &&
|
||||
($curlResult->getBody() != '') && (strlen($curlResult->getBody()) < 30)) {
|
||||
|
||||
|
@ -1639,9 +1639,9 @@ class GServer
|
|||
{
|
||||
// There is a bug in some versions of Friendica that will return an ActivityStream actor when the content type "application/json" is requested.
|
||||
// Because of this me must not use ACCEPT_JSON here.
|
||||
$curlResult = DI::httpClient()->get($url . '/friendica/json', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_DEFAULT]);
|
||||
$curlResult = DI::httpClient()->get($url . '/friendica/json', [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::DEFAULT]);
|
||||
if (!$curlResult->isSuccess()) {
|
||||
$curlResult = DI::httpClient()->get($url . '/friendika/json', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_DEFAULT]);
|
||||
$curlResult = DI::httpClient()->get($url . '/friendika/json', [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::DEFAULT]);
|
||||
$friendika = true;
|
||||
$platform = 'Friendika';
|
||||
} else {
|
||||
|
@ -1946,7 +1946,7 @@ class GServer
|
|||
$protocols = ['activitypub', 'diaspora', 'dfrn', 'ostatus'];
|
||||
foreach ($protocols as $protocol) {
|
||||
$query = '{nodes(protocol:"' . $protocol . '"){host}}';
|
||||
$curlResult = DI::httpClient()->fetch('https://the-federation.info/graphql?query=' . urlencode($query), 0, HttpClient::ACCEPT_JSON);
|
||||
$curlResult = DI::httpClient()->fetch('https://the-federation.info/graphql?query=' . urlencode($query), 0, HttpClientAccept::JSON);
|
||||
if (!empty($curlResult)) {
|
||||
$data = json_decode($curlResult, true);
|
||||
if (!empty($data['data']['nodes'])) {
|
||||
|
@ -1963,7 +1963,7 @@ class GServer
|
|||
|
||||
if (!empty($accesstoken)) {
|
||||
$api = 'https://instances.social/api/1.0/instances/list?count=0';
|
||||
$curlResult = DI::httpClient()->get($api, [HttpClientOptions::HEADERS => ['Authorization' => ['Bearer ' . $accesstoken]], HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_JSON]);
|
||||
$curlResult = DI::httpClient()->get($api, [HttpClientOptions::HEADERS => ['Authorization' => ['Bearer ' . $accesstoken]], HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON]);
|
||||
if ($curlResult->isSuccess()) {
|
||||
$servers = json_decode($curlResult->getBody(), true);
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ use Friendica\Core\Storage\Exception\InvalidClassStorageException;
|
|||
use Friendica\Core\Storage\Exception\ReferenceStorageException;
|
||||
use Friendica\Core\Storage\Exception\StorageException;
|
||||
use Friendica\Core\Storage\Type\SystemResource;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClient;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientOptions;
|
||||
use Friendica\Object\Image;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
|
@ -499,7 +499,7 @@ class Photo
|
|||
|
||||
$filename = basename($image_url);
|
||||
if (!empty($image_url)) {
|
||||
$ret = DI::httpClient()->get($image_url, [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_IMAGE]);
|
||||
$ret = DI::httpClient()->get($image_url, [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::IMAGE]);
|
||||
Logger::debug('Got picture', ['Content-Type' => $ret->getHeader('Content-Type'), 'url' => $image_url]);
|
||||
$img_str = $ret->getBody();
|
||||
$type = $ret->getContentType();
|
||||
|
@ -915,7 +915,7 @@ class Photo
|
|||
{
|
||||
$filename = basename($image_url);
|
||||
if (!empty($image_url)) {
|
||||
$ret = DI::httpClient()->get($image_url, [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_IMAGE]);
|
||||
$ret = DI::httpClient()->get($image_url, [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::IMAGE]);
|
||||
Logger::debug('Got picture', ['Content-Type' => $ret->getHeader('Content-Type'), 'url' => $image_url]);
|
||||
$img_str = $ret->getBody();
|
||||
$type = $ret->getContentType();
|
||||
|
|
|
@ -26,7 +26,7 @@ use Friendica\Core\System;
|
|||
use Friendica\Database\Database;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClient;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientOptions;
|
||||
use Friendica\Util\Proxy;
|
||||
|
||||
|
@ -97,7 +97,7 @@ class Link
|
|||
return $url . $id;
|
||||
}
|
||||
|
||||
private static function fetchMimeType(string $url, string $accept = HttpClient::ACCEPT_DEFAULT)
|
||||
private static function fetchMimeType(string $url, string $accept = HttpClientAccept::DEFAULT)
|
||||
{
|
||||
$timeout = DI::config()->get('system', 'xrd_timeout');
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ use Friendica\DI;
|
|||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Photo;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClient;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientOptions;
|
||||
use Friendica\Util\Images;
|
||||
use Friendica\Util\Network;
|
||||
|
@ -169,11 +169,11 @@ class Media
|
|||
// Fetch the mimetype or size if missing.
|
||||
if (empty($media['mimetype']) || empty($media['size'])) {
|
||||
$timeout = DI::config()->get('system', 'xrd_timeout');
|
||||
$curlResult = DI::httpClient()->head($media['url'], [HttpClientOptions::TIMEOUT => $timeout, HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_DEFAULT]);
|
||||
$curlResult = DI::httpClient()->head($media['url'], [HttpClientOptions::TIMEOUT => $timeout, HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::DEFAULT]);
|
||||
|
||||
// Workaround for systems that can't handle a HEAD request
|
||||
if (!$curlResult->isSuccess() && ($curlResult->getReturnCode() == 405)) {
|
||||
$curlResult = DI::httpClient()->get($media['url'], [HttpClientOptions::TIMEOUT => $timeout, HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_DEFAULT]);
|
||||
$curlResult = DI::httpClient()->get($media['url'], [HttpClientOptions::TIMEOUT => $timeout, HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::DEFAULT]);
|
||||
}
|
||||
|
||||
if ($curlResult->isSuccess()) {
|
||||
|
|
|
@ -35,7 +35,7 @@ use Friendica\Core\System;
|
|||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClient;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientOptions;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Protocol\Activity;
|
||||
|
@ -751,7 +751,7 @@ class Profile
|
|||
$magic_path = $basepath . '/magic' . '?owa=1&dest=' . $dest . '&' . $addr_request;
|
||||
|
||||
// We have to check if the remote server does understand /magic without invoking something
|
||||
$serverret = DI::httpClient()->head($basepath . '/magic', [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_HTML]);
|
||||
$serverret = DI::httpClient()->head($basepath . '/magic', [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::HTML]);
|
||||
if ($serverret->isSuccess()) {
|
||||
Logger::info('Doing magic auth for visitor ' . $my_url . ' to ' . $magic_path);
|
||||
System::externalRedirect($magic_path);
|
||||
|
|
|
@ -34,7 +34,7 @@ use Friendica\Core\System;
|
|||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClient;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientOptions;
|
||||
use Friendica\Security\TwoFactor\Model\AppSpecificPassword;
|
||||
use Friendica\Network\HTTPException;
|
||||
|
@ -1152,7 +1152,7 @@ class User
|
|||
$photo_failure = false;
|
||||
|
||||
$filename = basename($photo);
|
||||
$curlResult = DI::httpClient()->get($photo, [HttpClientOptions::ACCEPT_CONTENT => HttpClient::ACCEPT_IMAGE]);
|
||||
$curlResult = DI::httpClient()->get($photo, [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::IMAGE]);
|
||||
if ($curlResult->isSuccess()) {
|
||||
Logger::debug('Got picture', ['Content-Type' => $curlResult->getHeader('Content-Type'), 'url' => $photo]);
|
||||
$img_str = $curlResult->getBody();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue