[various] Introduce explicit HttpClient "Accept" parameter #1245

Merged
nupplaphil merged 4 commits from feat/http_client_arg into develop 2022-04-08 20:36:55 +02:00
5 changed files with 6 additions and 10 deletions
Showing only changes of commit 707e03635b - Show all commits

View file

@ -17,7 +17,6 @@ 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;
@ -193,7 +192,7 @@ EOT;
Logger::debug('dwpost: data: ' . $xml);
if ($dw_blog !== 'test') {
$x = DI::httpClient()->post($dw_blog, $xml, HttpClientAccept::DEFAULT, ['Content-Type' => 'text/xml'])->getBody();
$x = DI::httpClient()->post($dw_blog, $xml, ['Content-Type' => 'text/xml'])->getBody();
}
Logger::info('posted to dreamwidth: ' . ($x) ? $x : '');

View file

@ -16,7 +16,6 @@ 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;
@ -187,7 +186,7 @@ EOT;
Logger::debug('ijpost: data: ' . $xml);
if ($ij_blog !== 'test') {
$x = DI::httpClient()->post($ij_blog, $xml, HttpClientAccept::DEFAULT, ['Content-Type' => 'text/xml'])->getBody();
$x = DI::httpClient()->post($ij_blog, $xml, ['Content-Type' => 'text/xml'])->getBody();
}
Logger::info('posted to insanejournal: ' . $x ? $x : '');
}

View file

@ -17,7 +17,6 @@ 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;
@ -207,7 +206,7 @@ EOT;
Logger::debug('ljpost: data: ' . $xml);
if ($lj_blog !== 'test') {
$x = DI::httpClient()->post($lj_blog, $xml, HttpClientAccept::DEFAULT, ['Content-Type' => 'text/xml'])->getBody();
$x = DI::httpClient()->post($lj_blog, $xml, ['Content-Type' => 'text/xml'])->getBody();
}
Logger::info('posted to livejournal: ' . ($x) ? $x : '');
}

View file

@ -86,7 +86,7 @@ class WebDav implements ICanWriteToStorage
*/
protected function exists(string $uri): bool
{
return $this->client->head($uri, HttpClientAccept::DEFAULT, [HttpClientOptions::AUTH => $this->authOptions])->getReturnCode() == 200;
return $this->client->head($uri, [HttpClientOptions::AUTH => $this->authOptions])->getReturnCode() == 200;
}
/**
@ -178,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, HttpClientAccept::DEFAULT, [HttpClientOptions::AUTH => $this->authOptions]);
$response = $this->client->request('delete', $checkUrl, [HttpClientOptions::AUTH => $this->authOptions]);
if (!$response->isSuccess()) {
if ($response->getReturnCode() == "404") {

View file

@ -5,7 +5,6 @@ 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;
@ -139,7 +138,7 @@ class WebDavConfig implements ICanConfigureStorage
];
}
if (!$this->client->head($url, HttpClientAccept::DEFAULT, [HttpClientOptions::AUTH => $options])->isSuccess()) {
if (!$this->client->head($url, [HttpClientOptions::AUTH => $options])->isSuccess()) {
return [
'url' => $this->l10n->t('url is either invalid or not reachable'),
];