use Friendica\Core\Storage\Capability\ICanWriteToStorage;
use Friendica\Core\Storage\Exception\ReferenceStorageException;
use Friendica\Core\Storage\Exception\StorageException;
-use Friendica\Network\HTTPClientOptions;
-use Friendica\Network\IHTTPClient;
+use Friendica\Network\HTTPClient\Client\HttpClientOptions;
+use Friendica\Network\HTTPClient\Capability\ICanRequestPerHttp;
use Friendica\Util\Strings;
use Psr\Log\LoggerInterface;
/** @var string */
private $url;
- /** @var IHTTPClient */
+ /** @var ICanRequestPerHttp */
private $client;
/** @var LoggerInterface */
/**
* WebDav constructor
*
- * @param string $url The full URL to the webdav endpoint (including the subdirectories)
- * @param array $authOptions The authentication options for the http calls ( ['username', 'password', 'auth_type'] )
- * @param IHTTPClient $client The http client for communicating with the WebDav endpoint
- * @param LoggerInterface $logger The standard logging class
+ * @param string $url The full URL to the webdav endpoint (including the subdirectories)
+ * @param array $authOptions The authentication options for the http calls ( ['username', 'password', 'auth_type'] )
+ * @param ICanRequestPerHttp $client The http client for communicating with the WebDav endpoint
+ * @param LoggerInterface $logger The standard logging class
*/
- public function __construct(string $url, array $authOptions, IHTTPClient $client, LoggerInterface $logger)
+ public function __construct(string $url, array $authOptions, ICanRequestPerHttp $client, LoggerInterface $logger)
{
$this->client = $client;
$this->logger = $logger;
*/
protected function exists(string $uri): bool
{
- return $this->client->head($uri, [HTTPClientOptions::AUTH => $this->authOptions])->getReturnCode() == 200;
+ return $this->client->head($uri, [HttpClientOptions::AUTH => $this->authOptions])->getReturnCode() == 200;
}
/**
$dom->appendChild($root)->appendChild($prop);
$opts = [
- HTTPClientOptions::AUTH => $this->authOptions,
- HTTPClientOptions::HEADERS => ['Depth' => 1, 'Prefer' => 'return-minimal', 'Content-Type' => 'application/xml'],
- HTTPClientOptions::BODY => $dom->saveXML(),
+ HttpClientOptions::AUTH => $this->authOptions,
+ HttpClientOptions::HEADERS => ['Depth' => 1, 'Prefer' => 'return-minimal', 'Content-Type' => 'application/xml'],
+ HttpClientOptions::BODY => $dom->saveXML(),
];
$response = $this->client->request('propfind', $uri, $opts);
*/
protected function mkcol(string $uri): bool
{
- return $this->client->request('mkcol', $uri, [HTTPClientOptions::AUTH => $this->authOptions])
+ return $this->client->request('mkcol', $uri, [HttpClientOptions::AUTH => $this->authOptions])
->getReturnCode() == 200;
}
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, [HttpClientOptions::AUTH => $this->authOptions]);
if (!$response->isSuccess()) {
if ($response->getReturnCode() == "404") {
{
$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], [HttpClientOptions::AUTH => $this->authOptions]);
if (!$response->isSuccess()) {
throw new ReferenceStorageException(sprintf('Invalid reference %s', $reference));
$this->checkAndCreatePath($file[1]);
$opts = [
- HTTPClientOptions::BODY => $data,
- HTTPClientOptions::AUTH => $this->authOptions,
+ HttpClientOptions::BODY => $data,
+ HttpClientOptions::AUTH => $this->authOptions,
];
$this->client->request('put', $this->url . '/' . $file[0], $opts);
{
$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], [HttpClientOptions::AUTH => $this->authOptions]);
if (!$response->isSuccess()) {
throw new ReferenceStorageException(sprintf('Invalid reference %s', $reference));
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\L10n;
use Friendica\Core\Storage\Capability\ICanConfigureStorage;
-use Friendica\Network\HTTPClientOptions;
-use Friendica\Network\IHTTPClient;
+use Friendica\Network\HTTPClient\Client\HttpClientOptions;
+use Friendica\Network\HTTPClient\Capability\ICanRequestPerHttp;
/**
* The WebDav Backend Storage configuration class
/** @var string */
private $url;
- /** @var IHTTPClient */
+ /** @var \Friendica\Network\HTTPClient\Capability\ICanRequestPerHttp */
private $client;
/** @var array */
return $this->authOptions;
}
- public function __construct(L10n $l10n, IManageConfigValues $config, IHTTPClient $client)
+ public function __construct(L10n $l10n, IManageConfigValues $config, ICanRequestPerHttp $client)
{
$this->l10n = $l10n;
$this->config = $config;
];
}
- if (!$this->client->head($url, [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'),
];