]> git.mxchange.org Git - friendica.git/blobdiff - src/Util/ParseUrl.php
remove unused $redirect parameter
[friendica.git] / src / Util / ParseUrl.php
index 79c3928d7de5703e749f7691912b2f8b1dcda5fa..915a143a0473b87cb2f0de059ed0d84b13e2ebc2 100644 (file)
@@ -63,7 +63,7 @@ class ParseUrl
                        return [];
                }
 
-               $contenttype =  $curlResult->getHeader('Content-Type');
+               $contenttype =  $curlResult->getHeader('Content-Type')[0] ?? '';
                if (empty($contenttype)) {
                        return [];
                }
@@ -213,19 +213,14 @@ class ParseUrl
                        return $siteinfo;
                }
 
-               $curlResult = DI::httpRequest()->get($url, false, ['content_length' => 1000000]);
+               $curlResult = DI::httpRequest()->get($url, ['content_length' => 1000000]);
                if (!$curlResult->isSuccess() || empty($curlResult->getBody())) {
                        return $siteinfo;
                }
 
                $siteinfo['expires'] = DateTimeFormat::utc(self::DEFAULT_EXPIRATION_SUCCESS);
 
-               // If the file is too large then exit
-               if (($curlResult->getInfo()['download_content_length'] ?? 0) > 1000000) {
-                       return $siteinfo;
-               }
-
-               if ($cacheControlHeader = $curlResult->getHeader('Cache-Control')) {
+               if ($cacheControlHeader = $curlResult->getHeader('Cache-Control')[0] ?? '') {
                        if (preg_match('/max-age=([0-9]+)/i', $cacheControlHeader, $matches)) {
                                $maxAge = max(86400, (int)array_pop($matches));
                                $siteinfo['expires'] = DateTimeFormat::utc("now + $maxAge seconds");
@@ -272,10 +267,8 @@ class ParseUrl
                $charset = '';
                // Look for a charset, first in headers
                // Expected form: Content-Type: text/html; charset=ISO-8859-4
-               foreach ($curlResult->getContentType() as $type) {
-                       if (preg_match('/charset=([a-z0-9-_.\/]+)/i', $type, $matches)) {
-                               $charset = trim(trim(trim(array_pop($matches)), ';,'));
-                       }
+               if (preg_match('/charset=([a-z0-9-_.\/]+)/i', $curlResult->getContentType(), $matches)) {
+                       $charset = trim(trim(trim(array_pop($matches)), ';,'));
                }
 
                // Then in body that gets precedence