<?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\HTTPClient\Client\HttpClient;
+use Friendica\Network\HTTPClient\Client\HttpClientOptions;
use Friendica\Network\HTTPException\NotModifiedException;
use Friendica\Object\Image;
use Friendica\Util\HTTPSignature;
/**
* Fetch remote image content
*/
- public static function rawContent()
+ protected function rawContent(array $request = [])
{
- $request = self::getRequestInfo();
+ $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'] ?? '']);
$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)) {
// 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);
* ]
* @throws \Exception
*/
- private static function getRequestInfo()
+ private function getRequestInfo()
{
$size = ProxyUtils::PIXEL_LARGE;
$sizetype = '';
- if (!empty(static::$parameters['url']) && empty($_REQUEST['url'])) {
- $url = static::$parameters['url'];
+ if (!empty($this->parameters['url']) && empty($_REQUEST['url'])) {
+ $url = $this->parameters['url'];
// thumb, small, medium and large.
if (substr($url, -6) == ':micro') {