From 8c5c7794152e8d84820e61c8dc4069eb5d32a36a Mon Sep 17 00:00:00 2001 From: Solderpunk Date: Mon, 14 Oct 2019 19:47:02 +0300 Subject: [PATCH] Permit manual control of redirects. --- av98.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/av98.py b/av98.py index 2c4ae17..b79a050 100755 --- a/av98.py +++ b/av98.py @@ -205,6 +205,7 @@ class GeminiClient(cmd.Cmd): "ipv6" : True, "timeout" : 10, "gopher_proxy" : "localhost:1965", + "auto_follow_redirects" : True, } self.log = { @@ -284,7 +285,11 @@ Slow internet connection? Use 'set timeout' to be more patient.""") # Redirects elif status.startswith("3"): new_gi = GeminiItem(gi.absolutise_url(meta)) - if new_gi.url in self.previous_redirectors: + if not self.options["auto_follow_redirects"]: + follow = input("Follow redirect to %s? (y/n) " % new_gi.url) + if follow.strip().lower() in ("y", "yes"): + self._go_to_gi(new_gi) + elif new_gi.url in self.previous_redirectors: print("Error: caught in redirect loop!") elif len(self.previous_redirectors) == _MAX_REDIRECTS: print("Error: refusing to follow more than %d consecutive redirects!" % _MAX_REDIRECTS)