From 50be14a327be8ab79b9b61bef1768935a6485357 Mon Sep 17 00:00:00 2001 From: Solderpunk Date: Sat, 22 Jun 2019 16:02:11 +0300 Subject: [PATCH] Handle redirects and Not Found errors. --- av98.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/av98.py b/av98.py index 80802b2..5d855d1 100755 --- a/av98.py +++ b/av98.py @@ -276,6 +276,17 @@ Slow internet connection? Use 'set timeout' to be more patient.""") print("ERROR: " + str(err)) return + # Handle redirects + # (Temporarily accepting unofficial conman status codes) + if status in ("3", "301"): + self._debug("Following redirect to %s." % mime) + new_gi = GeminiItem(gi.host, gi.port, mime, None) + self._go_to_gi(new_gi) + return + elif status in ("4", "404"): + print("Path %s does not exist at %s:%d" % (gi.path, gi.host, gi.port)) + return + # Save the result in a temporary file ## Delete old file if self.tmp_filename: