simplepie / simplepie

A simple Atom/RSS parsing library for PHP.
http://simplepie.org/
1.54k stars 387 forks source link

[ENH] Allow custom headers to configure for feed #833

Open gjimish opened 1 year ago

gjimish commented 1 year ago

Is your feature request related to a problem? Please describe.

Allow to pass other headers as well for feed url.

Describe the solution you'd like

https://github.com/simplepie/simplepie/blob/adc91d455d2247ad4eb9febef0c275a780780cad/src/SimplePie.php#L1732-L1734 should be configurable.

Describe alternatives you've considered

N/A

Additional context

I can submit a PR.

Art4 commented 1 year ago

By allowing a PSR-18 HTTP client the headers could be changed easily. See #777 and #826.

jtojnar commented 1 year ago

I am not sure changing headers is a meaningful operation. SimplePie can make multiple HTTP requests and you probably do not want to set a single Accept header for all of them.

Supplying a custom PSR-18 client with middleware that adjusts headers per request will be probably a better idea. And you do not need to wait for PSR-18 support, you can pass a custom client, that does whatever with headers, today. We do that in selfoss: https://github.com/fossar/selfoss/blob/c49337513662e772c52235f3617f98a13071cdac/src/helpers/FeedReader.php#L33