roach-php / core

The complete web scraping toolkit for PHP.

Home Page:https://roach-php.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Responses dropped by middlewares are not registered

Fadarrizz opened this issue · comments

Firstly, I really like this package. Really nice work!

In my app, I want to act based on the fact if the ExecuteJavascriptMiddleware drops a response.

However, this is not registered anywhere besides info logging, resulting in an empty array of items without an exception or event raised.

After digging in, I saw the Downloader class doesn't do anything when noticing a dropped response by a middleware (Downloader.php, line 131-137):

        ...
        foreach ($this->middleware as $middleware) {
            $response = $middleware->handleResponse($response);

            if ($response->wasDropped()) {
                return;
            }
        }
       ...

Shouldn't this dispatch a ResponseDropped event or something else?

I'm willing to provide a PR if we can figure out a solution.

Thanks for the help!

You're right, this is a bug. Thanks for pointing this out!

I will fix this in a future version since there are other things around the ResponseDropped event that aren't working as intended at the moment.