cuprite icon indicating copy to clipboard operation
cuprite copied to clipboard

Fix request interception when using a black/whitelist

Open jimryan opened this issue 4 years ago • 3 comments

This PR aims to resolve two issues:

  1. Intercepted requests would always be continued when a black or whitelist was used, regardless of if the callback that applies the white/blacklist was the last callback. This prohibited callbacks registered after cuprite's from aborting the request or responding to it, since it was already continued.
  2. Whitelists and blacklists could not be combined. If a blacklist was configured, the whitelist was never considered, and the request was either aborted or continued based on if it matched the blacklist or not.

The callback that applies the black/whitelist now:

  1. Aborts the request and stops if the blacklist is configured and the request matches it.
  2. Aborts the request and stops if the whitelist is configured and the request does not match it.
  3. Continues the request if there are no other callbacks.
  4. Does nothing if the request does not match the blacklist, matches the whitelist, and there are other callbacks.

I also question if continuing the request should be the callback's responsibility or not, or if Ferrum should just continue it if no callbacks responded or aborted. As things stand, all callbacks need to do something like this.


Thank you so much for cuprite/ferrum, my test suites run faster, are easier to debug, and I actually understand what's going on and can read the code powering the entire stack. Awesome work ❤️

jimryan avatar Dec 09 '20 00:12 jimryan

Sorry for a late reply, tough time. I'll start checking all the PRs and Issues and prepare a release.

route avatar Jan 11 '21 19:01 route

@route Totally understandable! Thanks. Let me know if I can help in any way.

jimryan avatar Jan 11 '21 19:01 jimryan

Hi @jimryan! Thank you for your contribution! Can you please merge/rebase PR with the updated master, let's see how CI goes

Mifrill avatar Aug 29 '21 16:08 Mifrill