/** * Tell if a file should be cached or not */ private function cacheable_item($data, &$reason) { $reason = ""; if ($data['info']['size_download'] > $this->maxFileSize * 1024) { $reason = "File size too large"; return FALSE; } if (isset($data['headers']['Content-Type']) && !empty($this->excludedContentTypes)) { $content_type = $data['headers']['Content-Type']; foreach ($this->excludedContentTypes as $exclude) { if (trim($exclude) && strpos(strtolower($content_type), trim($exclude)) !== FALSE) { $reason = "Content type not allowed"; return FALSE; } } } if (AmberNetworkUtils::find_meta_no_archive($data['body'])) { $reason = "noarchive/noindex meta tag found"; return FALSE; } return TRUE; }
public function testMetaNoArchiveTagDetectionNoIndex() { $this->assertTrue(AmberNetworkUtils::find_meta_no_archive(<<<EOD <html> <head><title>bad man</title> <meta name="robots" content="noindex"> </head> <body> The meta tag only works in the head </body> </html> EOD )); $this->assertTrue(AmberNetworkUtils::find_meta_no_archive(<<<EOD <html> <head><title>bad man</title> <meta name="robots" content="noindex"> </head> <body> The meta tag only works in the head </body> </html> EOD )); $this->assertTrue(AmberNetworkUtils::find_meta_no_archive(<<<EOD <html> <head><title>bad man</title> <meta name="amber" content="noarchive, noindex"> </head> <body> The meta tag only works in the head </body> </html> EOD )); $this->assertTrue(AmberNetworkUtils::find_meta_no_archive(<<<EOD <html> <head><title>bad man</title> <meta name="robots" content="noindex,noarchive"> </head> <body> The meta tag only works in the head </body> </html> EOD )); }