AV-98-fork

A fork of https://tildegit.org/solderpunk/AV-98
Log (Feed) | Files | Refs (Tags) | README | LICENSE

commit 8c5c7794152e8d84820e61c8dc4069eb5d32a36a
parent a0e4acf3526e60339674bb8e2baabb1010b7ea69
Author: Solderpunk <solderpunk@sdf.org>
Date:   Mon, 14 Oct 2019 19:47:02 +0300

Permit manual control of redirects.

Diffstat:
Mav98.py | 7++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git 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)