]> git.mxchange.org Git - friendica.git/blobdiff - src/Content/Text/BBCode.php
Merge pull request #10636 from nupplaphil/feat/httpclient_followup
[friendica.git] / src / Content / Text / BBCode.php
index 200c951de32e841d7dc16495a34e8db30a61e567..5a2b966dd57c2ce6501522409e111e84d9c263ed 100644 (file)
@@ -39,6 +39,7 @@ use Friendica\Model\Event;
 use Friendica\Model\Photo;
 use Friendica\Model\Post;
 use Friendica\Model\Tag;
+use Friendica\Network\HTTPClientOptions;
 use Friendica\Object\Image;
 use Friendica\Protocol\Activity;
 use Friendica\Util\Images;
@@ -51,7 +52,7 @@ use Friendica\Util\XML;
 class BBCode
 {
        // Update this value to the current date whenever changes are made to BBCode::convert
-       const VERSION = '2021-07-13';
+       const VERSION = '2021-07-28';
 
        const INTERNAL = 0;
        const EXTERNAL = 1;
@@ -493,7 +494,7 @@ class BBCode
                                        continue;
                                }
 
-                               $curlResult = DI::httpRequest()->get($mtch[1]);
+                               $curlResult = DI::httpClient()->get($mtch[1]);
                                if (!$curlResult->isSuccess()) {
                                        continue;
                                }
@@ -1193,9 +1194,9 @@ class BBCode
                $text = DI::cache()->get($cache_key);
 
                if (is_null($text)) {
-                       $curlResult = DI::httpRequest()->head($match[1], ['timeout' => DI::config()->get('system', 'xrd_timeout')]);
+                       $curlResult = DI::httpClient()->head($match[1], [HTTPClientOptions::TIMEOUT => DI::config()->get('system', 'xrd_timeout')]);
                        if ($curlResult->isSuccess()) {
-                               $mimetype = $curlResult->getHeader('Content-Type');
+                               $mimetype = $curlResult->getHeader('Content-Type')[0] ?? '';
                        } else {
                                $mimetype = '';
                        }
@@ -1206,7 +1207,7 @@ class BBCode
                                $text = "[url=" . $match[2] . ']' . $match[2] . "[/url]";
 
                                // if its not a picture then look if its a page that contains a picture link
-                               $body = DI::httpRequest()->fetch($match[1]);
+                               $body = DI::httpClient()->fetch($match[1]);
                                if (empty($body)) {
                                        DI::cache()->set($cache_key, $text);
                                        return $text;
@@ -1264,9 +1265,9 @@ class BBCode
                        return $text;
                }
 
-               $curlResult = DI::httpRequest()->head($match[1], ['timeout' => DI::config()->get('system', 'xrd_timeout')]);
+               $curlResult = DI::httpClient()->head($match[1], [HTTPClientOptions::TIMEOUT => DI::config()->get('system', 'xrd_timeout')]);
                if ($curlResult->isSuccess()) {
-                       $mimetype = $curlResult->getHeader('Content-Type');
+                       $mimetype = $curlResult->getHeader('Content-Type')[0] ?? '';
                } else {
                        $mimetype = '';
                }
@@ -1282,7 +1283,7 @@ class BBCode
                        }
 
                        // if its not a picture then look if its a page that contains a picture link
-                       $body = DI::httpRequest()->fetch($match[1]);
+                       $body = DI::httpClient()->fetch($match[1]);
                        if (empty($body)) {
                                DI::cache()->set($cache_key, $text);
                                return $text;