Skip to content

Add Accept-Encoding header to fetch method#283

Open
gRegorLove wants to merge 1 commit into
microformats:mainfrom
gRegorLove:dev/208
Open

Add Accept-Encoding header to fetch method#283
gRegorLove wants to merge 1 commit into
microformats:mainfrom
gRegorLove:dev/208

Conversation

@gRegorLove

Copy link
Copy Markdown
Member

Closes #208

@gRegorLove gRegorLove added this to the 0.5.1 milestone Jun 25, 2026
Comment thread Mf2/Parser.php
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
curl_setopt($ch, CURLOPT_ENCODING, '');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in #208 (comment), this option was renamed so ideally, it would be replaced with CURLOPT_ACCEPT_ENCODING conditional on version (see e.g. simplepie/simplepie#960).

This is not that critical right now since the current version of php keep the old name as alias. But will cause a warning once we introduce static analysis (something I plan to do soon).

Comment thread Mf2/Parser.php
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
curl_setopt($ch, CURLOPT_ENCODING, '');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also this will break sites whose servers send encodings that curl does not support. We might receive bug reports like simplepie/simplepie#961 and then we will either have to decide that we refuse to support that, or implement retry like https://github.com/simplepie/simplepie/pull/962/commits

@Zegnat

Zegnat commented Jun 27, 2026

Copy link
Copy Markdown
Member

I do not think we have to be known for fetching, or supporting all those cases. So I would lean towards not supporting retries. It is always possible for someone to feed the data into Mf2\parse after they have gotten it themselves.

It would be good to support both constants, as @jtojnar says, based on the data that PHP gives us:

  1. CURLOPT_ENCODING: “Available as of cURL 7.10 and deprecated as of cURL 7.21.6.”
  2. CURLOPT_ACCEPT_ENCODING: “Available as of cURL 7.21.6.”

Probably just based on curl_version(), using version_compare()? Again, unlike SimplePie, I would not try to make that logic any harder than it has to be.

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.

Support compression in fetch()

3 participants