yii2-httpclient
yii2-httpclient copied to clipboard
RFE: please, implement handling return value from beforeSend
In StreamTransport::send()
public function send($request)
{
$request->beforeSend();
$request->prepare();
...
Also in Request::beforeSend()
public function beforeSend()
{
$this->client->beforeSend($this);
$event = new RequestEvent();
...
We need to handle return value from beforeSend to cancel sending, like ActiveRecord do:
protected function updateInternal($attributes = null)
{
if (!$this->beforeSave(false)) {
return false;
}
...
For ex. I want to implement response caching behavior for Client. So, if response is already in cache, then onBeforeSend return false and sending must stop.
Sounds good. Can be released in 2.1.0 since it changes existing behavior.
Existing implementations return void, so, checking === false ..... Thank you :)