Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please consider allowing compressed content encodings #26

Open
cbiffle opened this issue Jan 18, 2024 · 0 comments
Open

Please consider allowing compressed content encodings #26

cbiffle opened this issue Jan 18, 2024 · 0 comments

Comments

@cbiffle
Copy link

cbiffle commented Jan 18, 2024

Hi! First off, it seems that a lot of people are using your library -- congrats! Thank you for identifying it in the user-agent string.

I operate a website and, collectively, requests identifying themselves as coming from this library are starting to be a significant fraction of my bytes transferred. This is mostly because

  • It seems to issue requests for / on the server, which is an HTML page -- not a favicon, but ok
  • It doesn't support content-encoding for compressing data in flight.

Because it's fetching raw HTML so often, it's moving about 8-10x more bytes on each request than it would using accept-encoding: gzip. This is why it's come up in my analysis -- other libraries are pinging me more often, but are doing so in more efficient ways.

It's been 20 years since I did any PHP, or I'd offer a patch. From reading several related StackOverflow articles, it seems like the simplest way to send fancier HTTP requests would be to switch to using cURL instead of file_get_contents. But, I imagine there might be reasons why you don't want to do that, so, this page implies that detecting a gzipped response and applying gzdecode would suffice. Sending the accept-encodings header appears straightforward using the context mechanism that you're already using for other purposes.

Anyway, hope that's helpful.

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

No branches or pull requests

1 participant