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).
Please add a third parameter, options
, to the beforeRetry hooks. That's it.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too