got
got copied to clipboard
Add options parameter to beforeRetry hook
What problem are you trying to solve?
I am trying to write a hook that (automatically) first tries an HTTPS version of a website, and then if it fails, retries it without forcing the HTTPS version.
This is currently not possible to do as a got plugin, as in the control flow of "beforeRequest forces HTTPS" -> "request fails" -> "beforeRetry sets a flag to not force HTTPS" -> "beforeRequest doesn't force HTTPS this time" -> "request sent", you cannot "send" information between the beforeRetry hook and the second invocation of beforeRequest hook, due to the beforeRetry hook not having options
as a parameter, which is used everywhere else in got's ecosystem to pass around information between hooks.
(note that afterResponse doesn't cut it because the request may throw - not just return a 4xx/5xx - when requesting a https version of a website (e.g. the certs may throw).
Describe the feature
Please add a third parameter, options
, to the beforeRetry hooks. That's it.
Checklist
- [x] I have read the documentation and made sure this feature doesn't already exist.
@JaneJeon the options property was removed since got 12, but it is still available with error.options See changelog