<?php
/**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2022, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
use Friendica\Core\Logger;
use Friendica\Core\System;
use Friendica\DI;
+use Friendica\Network\HTTPException\NotModifiedException;
use Friendica\Object\Image;
use Friendica\Util\HTTPSignature;
use Friendica\Util\Images;
/**
* Fetch remote image content
*/
- public static function rawContent(array $parameters = [])
+ protected function rawContent(array $request = [])
{
- $request = self::getRequestInfo($parameters);
+ $request = $this->getRequestInfo();
if (!DI::config()->get('system', 'proxify_content')) {
Logger::notice('Proxy access is forbidden', ['request' => $request, 'agent' => $_SERVER['HTTP_USER_AGENT'] ?? '', 'accept' => $_SERVER['HTTP_ACCEPT'] ?? '']);
}
if (isset($_SERVER["HTTP_IF_MODIFIED_SINCE"])) {
- header("HTTP/1.1 304 Not Modified");
header("Last-Modified: " . gmdate("D, d M Y H:i:s", time()) . " GMT");
if (!empty($_SERVER["HTTP_IF_NONE_MATCH"])) {
header("Etag: " . $_SERVER["HTTP_IF_NONE_MATCH"]);
header_remove("Expires");
header_remove("Cache-Control");
}
- exit;
+ throw new NotModifiedException();
}
if (empty($request['url'])) {
* ]
* @throws \Exception
*/
- private static function getRequestInfo(array $parameters)
+ private function getRequestInfo()
{
$size = ProxyUtils::PIXEL_LARGE;
$sizetype = '';
- if (!empty($parameters['url']) && empty($_REQUEST['url'])) {
- $url = $parameters['url'];
+ if (!empty($this->parameters['url']) && empty($_REQUEST['url'])) {
+ $url = $this->parameters['url'];
// thumb, small, medium and large.
if (substr($url, -6) == ':micro') {