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

HTTP client: Support passing default request headers #449

Closed
clue opened this issue Apr 11, 2022 · 4 comments
Closed

HTTP client: Support passing default request headers #449

clue opened this issue Apr 11, 2022 · 4 comments
Milestone

Comments

@clue
Copy link
Member

clue commented Apr 11, 2022

Here's what this could potentially look like:

$browser = new React\Http\Browser();
$browser = $browser->withProtocolVersion('1.1'); // already supported
$browser = $browser->withHeader('User-Agent', 'ACME'); // could be useful?

$browser->get($url)->then(…);

This isn't currently supported, but seems reasonable and would also allow other packages to take advantage of custom HTTP request headers. What do you think about this?

@WyriHaximus
Copy link
Member

Seeing this pattern in my own projects where I do this for the Authorization header. So lets add this 👍

@bartvanhoutte
Copy link

👋 Unsetting a default header, would that happen through

$browser = $browser->withHeader('User-Agent', null);

or

$browser = $browser->withoutHeader('User-Agent')

What do you think?

@clue
Copy link
Member Author

clue commented May 24, 2022

👋 Unsetting a default header, would that happen through […]

$browser = $browser->withoutHeader('User-Agent')

@bartvanhoutte The idea is definitely to keep this in line with our existing interfaces. In particular, PSR-7 (HTTP messages) already define a withoutHeader() method, so I would absolutely go for this as well here 👍

@clue clue added this to the v1.8.0 milestone Aug 26, 2022
@clue
Copy link
Member Author

clue commented Sep 15, 2022

Closed via #461 :shipit:

@clue clue closed this as completed Sep 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants