Skip to content

Merge upstream#71

Open
Alkarex wants to merge 14 commits intofreshrssfrom
merge-upstream
Open

Merge upstream#71
Alkarex wants to merge 14 commits intofreshrssfrom
merge-upstream

Conversation

@Alkarex
Copy link
Member

@Alkarex Alkarex commented Mar 21, 2026

No description provided.

jtojnar and others added 13 commits January 18, 2026 09:32
`get_headers()` actually return `parsed_headers` property which we did not previously set.
…_url

Make it clearer what request it is from and match the getter method name.
It is slightly cleaner.
…ted_url

Make it clearer what request it is from and match the getter method name.
In 1.9.0, we extended `Sniffer` to take any `Response`, not just `File`, and had `Locator` pass it `Response`s. Unfortunately, `Sniffer` is not final so that change might have broken existing third-party subclasses only accepting `File`. (Though it will at least not fail with fatal contravariance error since PHP does not enforce Liskov Substitution Principle for constructors.)

Let’s go back to `Sniffer` only accepting `File`.
This should make it easier to parse for humans.
On PHP < 8.1.21, we will not be able to disable `CURLOPT_ACCEPT_ENCODING` by setting it to `NULL`:
php/php-src#11433
`curl_setopt` with such values will be a no-op so the secound `curl_exec` will still fail with `CURLE_BAD_CONTENT_ENCODING` and return an empty body.
Even worse, it will still report 200 in `CURLINFO_HTTP_CODE` so `FileClient` will not throw an exception because the `status_code` property is not 0.

Let’s extract the code so that we can create a fresh `CurlHandle` and later make the `CURLOPT_ACCEPT_ENCODING` conditional.

Unfortunately, since PHP 8.0 changed `curl_init` to return `CurlHandle` instead of `resource`, and PHPStan has no simple way to make the return type depend on PHP version, we have to resort to an ugly hack using `typeAliases`.
Setting the CURLOPT_ENCODING to 'none' is not officially supported by
cURL. Setting it in case of cURL receiving an invalid Content-Encoding
header from the server and re-trying would not fix the issue.

The current implementation already sets cURL up to send an Accept-Encoding
header with all supported encodings a couple of lines above this change.
If the fetch still returns a BAD_CONTENT_ENCODING error, the server already
ignored the Accept-Encoding headers once.

This change, instead of sending 'none' in a re-try, disables cURL's content
encoding handling (in practice, handling compression).

Co-authored-by: Jan Tojnar <jtojnar@gmail.com>
@Alkarex Alkarex changed the base branch from master to freshrss March 21, 2026 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants