Move handling of permanent redirects inside of _fetch_over_network().

This commit is contained in:
Solderpunk 2023-11-15 19:45:36 +01:00
parent 9e2cce7ce0
commit f78b6ff780
1 changed files with 5 additions and 6 deletions

11
av98.py
View File

@ -327,12 +327,6 @@ you'll be able to transparently follow links to Gopherspace!""")
print("Sorry, no support for {} links.".format(gi.scheme))
return
# Obey permanent redirects
if gi.url in self.permanent_redirects:
new_gi = GeminiItem(self.permanent_redirects[gi.url], name=gi.name)
self._go_to_gi(new_gi)
return
# Use local file, use cache, or hit the network if resource is not cached
if gi.scheme == "file":
mime = self._handle_local_file(gi)
@ -399,6 +393,11 @@ Slow internet connection? Use 'set timeout' to be more patient.""")
previous_redirectors = set()
while True:
# Obey permanent redirects
if gi.url in self.permanent_redirects:
gi = GeminiItem(self.permanent_redirects[gi.url], name=gi.name)
continue
# Send request to server
try:
status, meta, address, f = self._send_request(gi)