Move ACCEPT constants to own "enum" class
This commit is contained in:
parent
aed0b53925
commit
82f8c14633
8 changed files with 22 additions and 14 deletions
|
@ -17,6 +17,7 @@ use Friendica\DI;
|
|||
use Friendica\Model\Post;
|
||||
use Friendica\Model\Tag;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\XML;
|
||||
|
||||
|
@ -192,7 +193,7 @@ EOT;
|
|||
Logger::debug('dwpost: data: ' . $xml);
|
||||
|
||||
if ($dw_blog !== 'test') {
|
||||
$x = DI::httpClient()->post($dw_blog, $xml, ['Content-Type' => 'text/xml'])->getBody();
|
||||
$x = DI::httpClient()->post($dw_blog, $xml, HttpClientAccept::DEFAULT, ['Content-Type' => 'text/xml'])->getBody();
|
||||
}
|
||||
|
||||
Logger::info('posted to dreamwidth: ' . ($x) ? $x : '');
|
||||
|
|
|
@ -16,6 +16,7 @@ use Friendica\Core\Renderer;
|
|||
use Friendica\DI;
|
||||
use Friendica\Model\Tag;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\XML;
|
||||
|
||||
|
@ -186,7 +187,7 @@ EOT;
|
|||
Logger::debug('ijpost: data: ' . $xml);
|
||||
|
||||
if ($ij_blog !== 'test') {
|
||||
$x = DI::httpClient()->post($ij_blog, $xml, ['Content-Type' => 'text/xml'])->getBody();
|
||||
$x = DI::httpClient()->post($ij_blog, $xml, HttpClientAccept::DEFAULT, ['Content-Type' => 'text/xml'])->getBody();
|
||||
}
|
||||
Logger::info('posted to insanejournal: ' . $x ? $x : '');
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ use Friendica\DI;
|
|||
use Friendica\Model\Post;
|
||||
use Friendica\Model\Tag;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\XML;
|
||||
|
||||
|
@ -206,7 +207,7 @@ EOT;
|
|||
Logger::debug('ljpost: data: ' . $xml);
|
||||
|
||||
if ($lj_blog !== 'test') {
|
||||
$x = DI::httpClient()->post($lj_blog, $xml, ['Content-Type' => 'text/xml'])->getBody();
|
||||
$x = DI::httpClient()->post($lj_blog, $xml, HttpClientAccept::DEFAULT, ['Content-Type' => 'text/xml'])->getBody();
|
||||
}
|
||||
Logger::info('posted to livejournal: ' . ($x) ? $x : '');
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ use Friendica\Model\Contact;
|
|||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
|
||||
use Friendica\Protocol\Activity;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
|
||||
|
@ -207,7 +208,7 @@ function mailstream_do_images(&$item, &$attachments)
|
|||
continue;
|
||||
}
|
||||
$cookiejar = tempnam(System::getTempPath(), 'cookiejar-mailstream-');
|
||||
$curlResult = DI::httpClient()->fetchFull($url, 0, '', $cookiejar);
|
||||
$curlResult = DI::httpClient()->fetchFull($url, HttpClientAccept::DEFAULT, 0, $cookiejar);
|
||||
$attachments[$url] = [
|
||||
'data' => $curlResult->getBody(),
|
||||
'guid' => hash("crc32", $url),
|
||||
|
|
|
@ -22,6 +22,7 @@ use Friendica\Model\Group;
|
|||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientOptions;
|
||||
use Friendica\Protocol\Activity;
|
||||
use Friendica\Protocol\ActivityNamespace;
|
||||
|
@ -1487,7 +1488,7 @@ function pumpio_fetchallcomments(App $a, $uid, $id)
|
|||
|
||||
function pumpio_reachable($url)
|
||||
{
|
||||
return DI::httpClient()->get($url, [HttpClientOptions::TIMEOUT => 10])->isSuccess();
|
||||
return DI::httpClient()->get($url, HttpClientAccept::DEFAULT, [HttpClientOptions::TIMEOUT => 10])->isSuccess();
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -56,6 +56,7 @@ use Friendica\Model\Item;
|
|||
use Friendica\Model\Photo;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
|
||||
use Friendica\Protocol\Activity;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Strings;
|
||||
|
@ -1367,7 +1368,7 @@ function statusnet_convertmsg(App $a, $body)
|
|||
} elseif ($oembed_data->type != "link") {
|
||||
$body = str_replace($search, "[url=" . $expanded_url . "]" . $expanded_url . "[/url]", $body);
|
||||
} else {
|
||||
$img_str = DI::httpClient()->fetch($expanded_url, 4);
|
||||
$img_str = DI::httpClient()->fetch($expanded_url, HttpClientAccept::DEFAULT, 4);
|
||||
|
||||
$tempfile = tempnam(System::getTempPath(), "cache");
|
||||
file_put_contents($tempfile, $img_str);
|
||||
|
|
|
@ -6,6 +6,7 @@ use Exception;
|
|||
use Friendica\Core\Storage\Capability\ICanWriteToStorage;
|
||||
use Friendica\Core\Storage\Exception\ReferenceStorageException;
|
||||
use Friendica\Core\Storage\Exception\StorageException;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientOptions;
|
||||
use Friendica\Network\HTTPClient\Capability\ICanSendHttpRequests;
|
||||
use Friendica\Util\Strings;
|
||||
|
@ -85,7 +86,7 @@ class WebDav implements ICanWriteToStorage
|
|||
*/
|
||||
protected function exists(string $uri): bool
|
||||
{
|
||||
return $this->client->head($uri, [HttpClientOptions::AUTH => $this->authOptions])->getReturnCode() == 200;
|
||||
return $this->client->head($uri, HttpClientAccept::DEFAULT, [HttpClientOptions::AUTH => $this->authOptions])->getReturnCode() == 200;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -110,7 +111,7 @@ class WebDav implements ICanWriteToStorage
|
|||
HttpClientOptions::BODY => $dom->saveXML(),
|
||||
];
|
||||
|
||||
$response = $this->client->request('propfind', $uri, $opts);
|
||||
$response = $this->client->request('propfind', $uri, HttpClientAccept::DEFAULT, $opts);
|
||||
|
||||
$responseDoc = new \DOMDocument();
|
||||
$responseDoc->loadXML($response->getBody());
|
||||
|
@ -133,7 +134,7 @@ class WebDav implements ICanWriteToStorage
|
|||
*/
|
||||
protected function mkcol(string $uri): bool
|
||||
{
|
||||
return $this->client->request('mkcol', $uri, [HttpClientOptions::AUTH => $this->authOptions])
|
||||
return $this->client->request('mkcol', $uri, HttpClientAccept::DEFAULT, [HttpClientOptions::AUTH => $this->authOptions])
|
||||
->getReturnCode() == 200;
|
||||
}
|
||||
|
||||
|
@ -177,7 +178,7 @@ class WebDav implements ICanWriteToStorage
|
|||
foreach ($pathParts as $pathPart) {
|
||||
$checkUrl = $this->url . $partURL;
|
||||
if (!empty($partURL) && !$this->hasItems($checkUrl)) {
|
||||
$response = $this->client->request('delete', $checkUrl, [HttpClientOptions::AUTH => $this->authOptions]);
|
||||
$response = $this->client->request('delete', $checkUrl, HttpClientAccept::DEFAULT, [HttpClientOptions::AUTH => $this->authOptions]);
|
||||
|
||||
if (!$response->isSuccess()) {
|
||||
if ($response->getReturnCode() == "404") {
|
||||
|
@ -199,7 +200,7 @@ class WebDav implements ICanWriteToStorage
|
|||
{
|
||||
$file = $this->pathForRef($reference);
|
||||
|
||||
$response = $this->client->request('get', $this->url . '/' . $file[0], [HttpClientOptions::AUTH => $this->authOptions]);
|
||||
$response = $this->client->request('get', $this->url . '/' . $file[0], HttpClientAccept::DEFAULT, [HttpClientOptions::AUTH => $this->authOptions]);
|
||||
|
||||
if (!$response->isSuccess()) {
|
||||
throw new ReferenceStorageException(sprintf('Invalid reference %s', $reference));
|
||||
|
@ -229,7 +230,7 @@ class WebDav implements ICanWriteToStorage
|
|||
HttpClientOptions::AUTH => $this->authOptions,
|
||||
];
|
||||
|
||||
$this->client->request('put', $this->url . '/' . $file[0], $opts);
|
||||
$this->client->request('put', $this->url . '/' . $file[0], HttpClientAccept::DEFAULT, $opts);
|
||||
|
||||
return $reference;
|
||||
}
|
||||
|
@ -241,7 +242,7 @@ class WebDav implements ICanWriteToStorage
|
|||
{
|
||||
$file = $this->pathForRef($reference);
|
||||
|
||||
$response = $this->client->request('delete', $this->url . '/' . $file[0], [HttpClientOptions::AUTH => $this->authOptions]);
|
||||
$response = $this->client->request('delete', $this->url . '/' . $file[0], HttpClientAccept::DEFAULT, [HttpClientOptions::AUTH => $this->authOptions]);
|
||||
|
||||
if (!$response->isSuccess()) {
|
||||
throw new ReferenceStorageException(sprintf('Invalid reference %s', $reference));
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Friendica\Addon\webdav_storage\src;
|
|||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Storage\Capability\ICanConfigureStorage;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
|
||||
use Friendica\Network\HTTPClient\Client\HttpClientOptions;
|
||||
use Friendica\Network\HTTPClient\Capability\ICanSendHttpRequests;
|
||||
|
||||
|
@ -138,7 +139,7 @@ class WebDavConfig implements ICanConfigureStorage
|
|||
];
|
||||
}
|
||||
|
||||
if (!$this->client->head($url, [HttpClientOptions::AUTH => $options])->isSuccess()) {
|
||||
if (!$this->client->head($url, HttpClientAccept::DEFAULT, [HttpClientOptions::AUTH => $options])->isSuccess()) {
|
||||
return [
|
||||
'url' => $this->l10n->t('url is either invalid or not reachable'),
|
||||
];
|
||||
|
|
Loading…
Reference in a new issue