Force using proxy for http client
It is no secret that in some countries, the telegram is already blocked or will be blocked soon. I suggest to modify the code to pass the proxy options to the constructor of the Client class
For example:
- new method Telegram::getHttpClientOptions() { return []; }
- and use it in Request::initialize to pass result of method to the GuzzleHttp\Client
thanks.
I believe if you want to proxy your requests you can simply use custom guzzle client:
Request::setClient(new \GuzzleHttp\Client([
'base_uri' => 'https://api.telegram.org',
'proxy' => 'tcp://1.2.3.4:125',
]));
in hook script before handling the webhook.
@demon-ru Did @jacklul's suggestion work for you?
It might help me to use proxy. But will create a headache to track and repeat options for creating Client. It is hoped that there will not appear anything except base_uri.
Could you please explain your scenario a bit more so we can try to understand it better?
You'd like to proxy only certain requests?
Proxies will be used for all calls (in case of blocking). My task is to add the configuration options of the Client (http client). Not create a Сlient, knowing all the options and configuration rules. But just to add some options.
The proposed option will work. But I need to know and support all the other options and rules creation. Soothes while only that now it is only one option (base_url).
As you say, there are no special options required, just base_url.
So that should work perfectly fine for what you need. If at some point more options are required (which I honestly don't think so any time soon), we can revisit this issue.
Can we close off then for now?
Yes. Thank you.