mirror of
https://github.com/friendica/friendica
synced 2025-04-30 09:44:22 +02:00
A lot of Fixings
This commit is contained in:
parent
06371d29a6
commit
65ca164487
7 changed files with 16 additions and 25 deletions
|
@ -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");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue