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

[5.5] Allow default headers to be sent with requests #20590

Merged

Conversation

mateusjatenee
Copy link
Contributor

@mateusjatenee mateusjatenee commented Aug 16, 2017

This PR allows default headers to be sent with the requests. So, instead of having to override the call method or having to use something as

$this->withServerVariables([
    'HTTP_FOO' => 'bar'
]);

$this->get('/');

You can do

$this->withHeaders([
    'foo' => 'bar'
]);

$this->get('/');

You can also clean the headers with $this->cleanHeaders();

I've been having to send default headers quite a lot on an app and thought it would be cool to have it on the core. let me know what you all think

@DCzajkowski
Copy link
Contributor

I'd like to see a withHeader($name, $value) method too. Or just header($name, $value) to compliment that from Illuminate\Http\ResponseTrait

@taylorotwell
Copy link
Member

I would rather see it clear the headers after each test.

@mateusjatenee
Copy link
Contributor Author

mateusjatenee commented Aug 16, 2017

@DCzajkowski in the withHeader case, would it be "global" or only applied in the next request?

@taylorotwell what worries me is if the user needs to clear the headers on the same test, in another request. Any ideas?

Edit:
Have to leave for a bit, but I added a withHeader method @DCzajkowski. Take a look

@taylorotwell
Copy link
Member

Wouldn't they just call ->clearHeaders() manually in that case?

@mateusjatenee
Copy link
Contributor Author

@taylorotwell oh, I thought you were saying you would rather not have the clearHeaders method and just have it reset after each test. I believe the way it is set up it resets after each test? i can test it once I get home

@mateusjatenee
Copy link
Contributor Author

Added a commit to flush the headers on the tearDown method

@taylorotwell taylorotwell merged commit 8ce6c76 into laravel:master Aug 21, 2017
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

Successfully merging this pull request may close these issues.

3 participants