]> git.mxchange.org Git - friendica-addons.git/commitdiff
Move ACCEPT constants to own "enum" class
authorPhilipp <admin@philipp.info>
Sat, 2 Apr 2022 19:16:21 +0000 (21:16 +0200)
committerPhilipp <admin@philipp.info>
Sat, 2 Apr 2022 19:16:21 +0000 (21:16 +0200)
dwpost/dwpost.php
ijpost/ijpost.php
ljpost/ljpost.php
mailstream/mailstream.php
pumpio/pumpio.php
statusnet/statusnet.php
webdav_storage/src/WebDav.php
webdav_storage/src/WebDavConfig.php

index 286d8012745f58cf9e8576a66f38bbe0dade3196..bab93dff94e601411005c20c58add4d9b1f4b984 100644 (file)
@@ -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 : '');
index 79cd75c89375a1d89842fa9c77464c7dc0f6a472..832dff2c709e9fad4591bd43ae454e1e7322b9da 100644 (file)
@@ -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 : '');
        }
index 073a977e8b3e0952144531d912a2e0beba340c48..2fa5e782b043319d7b3a0583c926e25bdfe42f3a 100644 (file)
@@ -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 : '');
        }
index 33959e1e5e82185f2d5e9ba6f1ddd2d0672e6b2b..60d6412b465451494040d089326205077d161313 100644 (file)
@@ -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),
index 62ad77120dc4c2c2b19a7afb9d0e318ee2cca079..1253d376ad5b947343c2a62cb50c8320f0511979 100644 (file)
@@ -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();
 }
 
 /*
index b2582b86e496dcf64b3cd98d8a93b60d9633fc0e..6fc1469c243843d1566abefb77338c4c6f3cb86a 100644 (file)
@@ -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);
index de9fc47690baa16d24716f29d33774bbef72ae79..2e6b5b4e5bb5b22a5de12dba205a49c6f745f6cf 100644 (file)
@@ -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));
index 2236e97ab36de191419d2f2ad694ee0a261f58a1..4a0c3c6790c91cfe72ad2c5401f2c13cc9d620ae 100644 (file)
@@ -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'),
                        ];