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

RFE: please, implement handling return value from beforeSend #198

Open
dicrtarasov opened this issue Feb 7, 2020 · 2 comments
Open

RFE: please, implement handling return value from beforeSend #198

dicrtarasov opened this issue Feb 7, 2020 · 2 comments
Labels
severity:BC breaking Breaks backwards compatibility status:ready for adoption Feel free to implement this issue. type:enhancement Enhancement
Milestone

Comments

@dicrtarasov
Copy link

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.

@samdark samdark added type:enhancement Enhancement status:ready for adoption Feel free to implement this issue. severity:BC breaking Breaks backwards compatibility labels Feb 7, 2020
@samdark samdark added this to the 2.1.0 milestone Feb 7, 2020
@samdark
Copy link
Member

samdark commented Feb 7, 2020

Sounds good. Can be released in 2.1.0 since it changes existing behavior.

@dicrtarasov
Copy link
Author

Existing implementations return void, so, checking === false .....
Thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity:BC breaking Breaks backwards compatibility status:ready for adoption Feel free to implement this issue. type:enhancement Enhancement
Projects
None yet
Development

No branches or pull requests

2 participants