Fix Retry-After cache when proxy is used (#9508)

* Fix Retry-After cache when proxy is used

Because of #8029 and #8218, a proxy would never apply Retry-After.

Possibly related to the problem described in <https://github.com/FreshRSS/FreshRSS/pull/7760#issuecomment-6395796130> by @DamonHD.

* work around line length 168 instead of 165

* Update app/Models/Feed.php

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
This commit is contained in:
Frans de JongeandAlexandre Alapetite authored and GitHub committed 2026-10-26 20:44:26 +01:00
1 parent df96f25fd4
commit 54391ce1fb
2 files changed
+25 -5

No files matched your search

+8 -2
View File
@@ -105,9 +105,15 @@ class FreshRSS_Feed extends Minz_Model {
$this->hashFavicon(skipCache: true);
}
/** Must match the proxy of `FreshRSS_SimplePieCustom`, which stores `Retry-After`. */
public function proxyParam(): string {
$curl_params = FreshRSS_http_Util::sanitizeCurlParams($this->attributeArray('curl_params') ?? []);
return is_string($curl_params[CURLOPT_PROXY] ?? null) ? $curl_params[CURLOPT_PROXY] : '';
$curl_options = array_replace(FreshRSS_Context::systemConf()->curl_options,
FreshRSS_http_Util::sanitizeCurlParams($this->attributeArray('curl_params') ?? []));
$proxyType = $curl_options[CURLOPT_PROXYTYPE] ?? 0;
if (is_int($proxyType) && ($proxyType < 0 || $proxyType === 3)) { // 3 is legacy for NONE
return ''; // Proxy disabled for this feed
}
return is_string($curl_options[CURLOPT_PROXY] ?? null) ? $curl_options[CURLOPT_PROXY] : '';
}
/**
+17 -3
View File
@@ -5,10 +5,23 @@ use PHPUnit\Framework\Attributes\DataProvider;
final class FeedTest extends \PHPUnit\Framework\TestCase {
#[\Override]
protected function setUp(): void {
FreshRSS_Context::initSystem(reload: true);
}
#[\Override]
protected function tearDown(): void {
FreshRSS_Context::initSystem(reload: true); // Restore the default curl_options
}
#[DataProvider('provideStoredAndRequestedUrls')]
public function test_load_obeysRetryAfter(string $storedUrl, string $requestedUrl): void {
public function test_load_obeysRetryAfter(string $storedUrl, string $requestedUrl, string $systemProxy = ''): void {
if ($systemProxy !== '') {
FreshRSS_Context::systemConf()->_attribute('curl_options', [CURLOPT_PROXY => $systemProxy]);
}
$getRetryAfterFile = new ReflectionMethod(FreshRSS_http_Util::class, 'getRetryAfterFile');
$file = $getRetryAfterFile->invoke(null, $requestedUrl, '');
$file = $getRetryAfterFile->invoke(null, $requestedUrl, $systemProxy);
self::assertIsString($file);
self::assertTrue(touch($file, time() + 600));
try {
@@ -21,12 +34,13 @@ final class FeedTest extends \PHPUnit\Framework\TestCase {
}
}
/** @return array<string,array{string,string}> */
/** @return array<string,array{0:string,1:string,2?:string}> */
public static function provideStoredAndRequestedUrls(): array {
// On a local network, where Retry-After is per URL
return [
'HTML-encoded' => ['http://192.168.1.2/?action=display&amp;bridge=Example', 'http://192.168.1.2/?action=display&bridge=Example'],
'force_feed' => ['http://192.168.1.2/feed#force_feed', 'http://192.168.1.2/feed'],
'system proxy' => ['http://192.168.1.2/feed', 'http://192.168.1.2/feed', 'proxy.example.test:3128'],
];
}
}