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

Allow sending custom headers on fetch method. #259

Open
aaronfc opened this issue Aug 8, 2024 · 0 comments
Open

Allow sending custom headers on fetch method. #259

aaronfc opened this issue Aug 8, 2024 · 0 comments

Comments

@aaronfc
Copy link

aaronfc commented Aug 8, 2024

Currently the fetch method is not allowing almost any customization.

I found some webpages in which my requests were blocked because we were not sending the User-Agent header.

To do so, I copy pasted the fetch method and added the curl_setopt($curl, CURLOPT_USERAGENT, 'My User Agent/1.0'); option.

Alternatively, I think that sending an extra header like 'User-Agent: My User Agent/1.0' in the existing CURLOPT_HTTPHEADER option should have worked too.

I could have also done the request by myself and then used the parse method, but fetch includes some extra logic (checking content_type` and making sure the 'url' used is the correct one, that I would have had to replicate.

Proposal:

  • Make it possible to add extra headers (maybe as an optional extra parameter which is [] by default).
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