Please consider allowing compressed content encodings
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-encodingfor 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.