-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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::globalRequestMiddleware not reflected in RequestSending event #51980
Comments
I managed to reproduce this. Not sure what's going on but would appreciate any insights here. |
Thank you for reporting this issue! As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub. If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team. Thank you! |
So we dispatch |
I have a feeling this has come up before and that we labeled it as the expected behaviour. But unsure which issue that was. We might have to adjust the docs a little bit here. |
This is quite funny, we add the middleware to the Guzzle stack around June 24th, 2020. We then receive a first commit on Jan 25th, 2022 (63cb622) that solves a similar issue, the middleware is not being added before the request is started. This commit moves the The reason for this is that you first want your middleware to be on each subsequent request. We receive an exact similar commit last year (f03e652), this moves the I'm now proud to announce, that after 3 years hereby I'll be moving the last line so whenever we send a request, we always have the middleware hooked. 😆 |
@driesvints This should be solved now. |
Thanks @eduance |
Laravel Version
11.13.0
PHP Version
8.3.6
Database Driver & Version
No response
Description
Hello. I change user agent in
Http::globalRequestMiddleware
like below according to this link:When I use
RequestSending
event like the example in document I get another user agent:I get
GuzzleHttp/7
in log file:The expected User-Agent is Example Application/1.0. This happens with any modifications in header. The request that is actually get sent has the correct User Agent but the log shows invalid output. How can I get this fixed?
Steps To Reproduce
1- Create
app/Providers/HttpClientServiceProvider.php
:2- Register event in
app/Providers/EventServiceProvider.php
:3- Create
app/Listeners/LogHttpClientRequests.php
:4- Run
Http::get('https://example.com')
in tinker.The text was updated successfully, but these errors were encountered: