Handle redirects and Not Found errors.

This commit is contained in:
Solderpunk 2019-06-22 16:02:11 +03:00
parent b7a761365c
commit 50be14a327
1 changed files with 11 additions and 0 deletions

11
av98.py
View File

@ -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: