CodingAleCR / http_interceptor

A lightweight, simple plugin that allows you to intercept request and response objects and modify them if desired.
MIT License
134 stars 67 forks source link

Feature Request: Re-run requests #17

Closed chitgoks closed 4 years ago

chitgoks commented 4 years ago

Is it possible when in the response, you find something that needs for the request to be re-run?

CodingAleCR commented 4 years ago

As of right now there's not. You would have to check for this outside of the interceptor and do it manually. I could try to implement it but just out of curiosity: would you need to add parameters to the request or something like that?

chitgoks commented 4 years ago

no parameters. my use case for using your interceptor is there is no way in google sign in to know when an access token has expired so instead, i use interceptors to check the expiry time and refresh before sending the request

however i noticed the access token sometimes expires before expiry time and i have no idea why. so i find out about this only in response.

in case this happens i wish to call the request again from the interceptor (if its possible)

CodingAleCR commented 4 years ago

Ok, this seems more like a feature for a client, I think we could add a retry count and check for that when intercepting, that would mean that the request would have to be re-intercepted as well as the responses, is that the kind of behavior you want?

chitgoks commented 4 years ago

if that will work the same way as calling an http method (post/get/delete, etc) again, then yes. my goal is not having to call the url again.

i wonder if it is possible in the response, that you can call a method that will go back to the interceptResponse so it will re-run ?

CodingAleCR commented 4 years ago

The feature was implemented, waiting on release though. Hope it helps you! @chitgoks

CodingAleCR commented 4 years ago

Please take a look at Release 0.3.0. Feedback is always welcomed.