X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=src%2FModule%2FProxy.php;h=751b4a29846dbf3fe17348f9aedf305fd49f20ad;hb=69b7923df2beed71419bc38e61ca9755fad24b12;hp=15ef1c44128b70639fc337ef560a56f8023647f4;hpb=e6c054c27602a3acadac3c423273bdf748fcee27;p=friendica.git diff --git a/src/Module/Proxy.php b/src/Module/Proxy.php index 15ef1c4412..751b4a2984 100644 --- a/src/Module/Proxy.php +++ b/src/Module/Proxy.php @@ -1,6 +1,6 @@ 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'] ?? '']); @@ -53,7 +56,6 @@ class Proxy extends BaseModule } 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"]); @@ -65,7 +67,7 @@ class Proxy extends BaseModule header_remove("Expires"); header_remove("Cache-Control"); } - exit; + throw new NotModifiedException(); } if (empty($request['url'])) { @@ -81,7 +83,7 @@ class Proxy extends BaseModule $request['url'] = str_replace(' ', '+', $request['url']); // Fetch the content with the local user - $fetchResult = HTTPSignature::fetchRaw($request['url'], local_user(), ['accept_content' => [], 'timeout' => 10]); + $fetchResult = HTTPSignature::fetchRaw($request['url'], local_user(), [HttpClientOptions::ACCEPT_CONTENT => [HttpClient::ACCEPT_IMAGE], 'timeout' => 10]); $img_str = $fetchResult->getBody(); if (!$fetchResult->isSuccess() || empty($img_str)) { @@ -90,6 +92,8 @@ class Proxy extends BaseModule // stop. } + Logger::debug('Got picture', ['Content-Type' => $fetchResult->getHeader('Content-Type'), 'uid' => local_user(), 'image' => $request['url']]); + $mime = Images::getMimeTypeByData($img_str); $image = new Image($img_str, $mime); @@ -119,13 +123,13 @@ class Proxy extends BaseModule * ] * @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') {