]> git.mxchange.org Git - friendica.git/commitdiff
Another "curl" call is replaced with a standard call
authorMichael <heluecht@pirati.ca>
Tue, 4 May 2021 11:39:56 +0000 (11:39 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 4 May 2021 11:39:56 +0000 (11:39 +0000)
src/Content/Text/BBCode.php

index c639923e3b5afdd8a08a75a4baa892feda1ba94f..e121778296a862447397c14f45609d7a3a323135 100644 (file)
@@ -1175,20 +1175,15 @@ class BBCode
                        return $text;
                }
 
-               // Only fetch the header, not the content
-               $stamp1 = microtime(true);
-
-               $ch = @curl_init($match[1]);
-               @curl_setopt($ch, CURLOPT_NOBODY, true);
-               @curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
-               @curl_setopt($ch, CURLOPT_USERAGENT, DI::httpRequest()->getUserAgent());
-               @curl_exec($ch);
-               $curl_info = @curl_getinfo($ch);
-
-               DI::profiler()->saveTimestamp($stamp1, "network");
+               $curlResult = DI::httpRequest()->head($match[1], ['timeout' => DI::config()->get('system', 'xrd_timeout')]);
+               if ($curlResult->isSuccess()) {
+                       $mimetype = $curlResult->getHeader('Content-Type');
+               } else {
+                       $mimetype = '';
+               }
 
                // if its a link to a picture then embed this picture
-               if (substr($curl_info['content_type'], 0, 6) == 'image/') {
+               if (substr($mimetype, 0, 6) == 'image/') {
                        $text = '[img]' . $match[1] . '[/img]';
                } else {
                        if (!empty($match[3])) {